Shadowing Posted January 1, 2012 Share Posted January 1, 2012 Hey guys only thing i can find online is examples of showing how much time is left until a predetermind time. but what I need is how many minutes are left until the next hour hits anyone have any ideas on this? Im wanting to do it in UNIX time Link to comment https://forums.phpfreaks.com/topic/254153-how-to-show-how-many-minutes-are-left-in-the-current-hour/ Share on other sites More sharing options...
trq Posted January 1, 2012 Share Posted January 1, 2012 Have you tried actually writing some code? It's not rocket science. Link to comment https://forums.phpfreaks.com/topic/254153-how-to-show-how-many-minutes-are-left-in-the-current-hour/#findComment-1302972 Share on other sites More sharing options...
Shadowing Posted January 1, 2012 Author Share Posted January 1, 2012 yah this is the closest as I got $next = ($time + '+3600'); this puts me a hour ahead always which isnt what i need so I dont know how to predetermind the time of every hour Link to comment https://forums.phpfreaks.com/topic/254153-how-to-show-how-many-minutes-are-left-in-the-current-hour/#findComment-1302974 Share on other sites More sharing options...
trq Posted January 1, 2012 Share Posted January 1, 2012 Sorry but I would seriously consider getting a new hobby. Link to comment https://forums.phpfreaks.com/topic/254153-how-to-show-how-many-minutes-are-left-in-the-current-hour/#findComment-1302975 Share on other sites More sharing options...
Shadowing Posted January 1, 2012 Author Share Posted January 1, 2012 i can add time or subtract time. I can even compare time such as $current = time(); $future = ($current + '+3600'); $time_left = ($future - $current); i dont know how to have the $future as always the next hour coming up Link to comment https://forums.phpfreaks.com/topic/254153-how-to-show-how-many-minutes-are-left-in-the-current-hour/#findComment-1302979 Share on other sites More sharing options...
Shadowing Posted January 1, 2012 Author Share Posted January 1, 2012 oh wait lol i think i just realize how to do this maybe i dont need to figure out the hour that is approaching i just need to know that there are 60 minutes in a hour and compare how many minutes into the hour i am already Link to comment https://forums.phpfreaks.com/topic/254153-how-to-show-how-many-minutes-are-left-in-the-current-hour/#findComment-1302981 Share on other sites More sharing options...
trq Posted January 1, 2012 Share Posted January 1, 2012 I'll give you a hint, take a look at date. Link to comment https://forums.phpfreaks.com/topic/254153-how-to-show-how-many-minutes-are-left-in-the-current-hour/#findComment-1302986 Share on other sites More sharing options...
Shadowing Posted January 1, 2012 Author Share Posted January 1, 2012 yah I use date all the time I figured it out not sure if this is how you would do it. i'll add some notes incase someone else stumbles onto this. $time = the players time with their timezone offset in UNIX time stamp $ahead = date('i', $time); // displays users time in minutes $time_left = (60 - $ahead); // compares the minutes in the hour with how many minutes minutes are in a hour which is 60 echo $time_left; my way of thinking about how to do it was totally backwards. Link to comment https://forums.phpfreaks.com/topic/254153-how-to-show-how-many-minutes-are-left-in-the-current-hour/#findComment-1302989 Share on other sites More sharing options...
trq Posted January 1, 2012 Share Posted January 1, 2012 Numbers aren't strings. They should not be surrounded by quotes. Link to comment https://forums.phpfreaks.com/topic/254153-how-to-show-how-many-minutes-are-left-in-the-current-hour/#findComment-1302990 Share on other sites More sharing options...
Shadowing Posted January 1, 2012 Author Share Posted January 1, 2012 thanks for that information I first had '60' but it gave me a snytax error so i added the quotes in confusion. But really the reason i had a error was cuase i forgot a simi colon and didnt change it back lol. I acctually didnt add anything but my text editor made it show 60 as red and wasnt sure if that was good or bad ha. nice to know now that i dont need ' ' now that i know quotes are for strings i go look up what ' ' are for. cause ive seen people doing that. for instance the 'i' in the date function has it Link to comment https://forums.phpfreaks.com/topic/254153-how-to-show-how-many-minutes-are-left-in-the-current-hour/#findComment-1302994 Share on other sites More sharing options...
trq Posted January 1, 2012 Share Posted January 1, 2012 now that i know quotes are for strings i go look up what ' ' are for. cause I've seen people doing that. for instance the 'i' in the date function has it " and ' are both quotes. If you look at the man page for the date function it tells you the the $format argument is expected to be a string. Link to comment https://forums.phpfreaks.com/topic/254153-how-to-show-how-many-minutes-are-left-in-the-current-hour/#findComment-1302997 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.