How do I find what day a particular date falls on

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.

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

Comments

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.