Jump to content

Show time left


clown[NOR]

Recommended Posts

I think this will be quick... I'm making a script for a radio, to show the current show... I've got everything figured out... only problem is the time left... the end time is stored in the database formatted like this 00:00:00 so what I was thinking was just doing something like this:

 

$current_time = date("H:i:s");
$end_time = $dbField['end'];
$time_left = $current_time - $end_time;

 

but that didn't work :D so i tried to remove the :'s but that didnt work either... anyone who could please guide me in the right direction?

 

Thanks In Advance

- Clown

Link to comment
https://forums.phpfreaks.com/topic/50259-show-time-left/
Share on other sites

damn.. I thought I had solved it... but then I suddenly noticed... it was 1 hour wrong... can someone please help out on this one?

 

$ctime = date("H:i:s");
$etime = $dbField['end'];
$time_left = strtotime($etime) - strtotime($ctime);
$tl_hours = date("H", $time_left)."h ";
$tl_mins = date("i", $time_left)."m ";
$tl_secs = date("s", $time_left)."s ";
$time_left = $tl_hours.$tl_mins.$tl_secs;

 

Thanks In Advance

- Clown

Link to comment
https://forums.phpfreaks.com/topic/50259-show-time-left/#findComment-246720
Share on other sites

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.