Jump to content

how to show how many minutes are left in the current hour


Shadowing

Recommended Posts

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

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

 

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

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.

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.