tags:

views:

32

answers:

4

How would you create a countdown timer that counts the number of days until an event will occur?

A: 

You need to save a timestamp of that specific datetime, and count seconds to it :) and display them as days intval(seconds / 60 / 60 / 24)

canni
+1  A: 

If you want a client-side timer you could use a jQuery countdown.

See a live demo here.

Mark Byers
ah ha, this does make more sense... thank you sir
hsatterwhite
hsatterwhite said about PHP.
Alexander.Plutov
@Alexander.Plutov: He also said "[A jQuery countdown] does make more sense".
Mark Byers
A: 

Try googling it. There are plenty of tutorials and ready made solutions:

http://www.brighthub.com/internet/web-development/articles/9471.aspx

http://php.about.com/od/learnphp/ht/countdown_php.htm

Also, you may try Javascript to create cool countdown timer with background images like on this page: http://www.getgyan.com/

(EDIT: this link is just a demo, does not have code to do so).

shamittomar
A: 
$event_date = '11-11-2011';
$event_timestamp = strtotime($event_date);
$now_timestamp = time();
$diff = $event_timestamp - $now_timestamp;
$days = round ($diff/(24*60*60));
Alexander.Plutov