brenlei.com

PHP tutorials

Question:

How do I find out what day Christmas falls on this year?

Answer:

We can use the mktime with the date function to find all the information we're looking for. First we use mktime to get the timestamp for Christmas for the current year. Then we pass that timestamp with the appropriate formatting flags to the date function to display the day.

Example
$Christmas = mktime(0, 0, 0, 12, 25, date('Y'));
echo '<p>Christmas will fall on a ' . date('l', $Christmas) . ' this year</p>';

PHP Reference Manual

date - Returns a formatted date

mktime - Returns a UNIX timestamp

Dates

How do you display the date and format it?
Learn how to use the php date function and the format flags

Comments or questions relating to this article have been disabled. They will be back soon.