Jump to content

How to countdown using 2 timestamps?


unrelenting

Recommended Posts

I want to post a "time left" clock deal that gets refreshed with each page refresh but am uncertain how it's done.

 

If I have to unix timestamps, one representing now and one for a date in the future, how could I get it to subract the 2 and print out like this:

 

3 days 6 hours 14 minutes 12 seconds until the deadline

 

I know it should likely start like:

 

$timeleft = $futuretime - time();

 

But from there I am lost.

Link to comment
https://forums.phpfreaks.com/topic/150089-how-to-countdown-using-2-timestamps/
Share on other sites

Well you will want to set the format you return the time(); in before you compare them.

 

It depends on if your comparing unix time stamps or dates and times you put in. In your format.

 

There are a lot of usefull functions for time in php. Take a search for 'php time.'

 

This link look like it has some info also:

http://www.ozzu.com/programming-forum/compare-time-with-php-t69163.html

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.