Dec 082011
 

Here’s how to calculate the days until Christmas using PHP:

$daysuntilxmas = ceil((mktime(0,0,0,12,25,date('Y')) - time()) / 86400);
echo "There are $daysuntilxmas days to Xmas!";

You can combine this with my End of the day countdown javascript to have a realtime countdown with hours, minutes, and seconds. If you do that, decrement the $daysuntilxmas by 1 since you will already be counting partial days.

Hope that helps!

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)