Days Until Christmas in PHP

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!


Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *