1. Home
  2. Computing & Technology
  3. PHP / MySQL

What Day of the Week Does it Fall on?
Find out what day of the week a specified date falls on

By Angela Bradley, About.com

While some holidays (Easter for example) always fall on the same day of the week, others vary every year. If you want to find out what day of the week Halloween, Christmas, or even your birthday falls on, you can use PHP!

The first thing you need to do is use the mktime() function to create a timestamp for the day in question. In our example we will use Halloween.

$h = mktime(0, 0, 0, 10, 31, 2008);

Next you can format this date in different ways using standard date formatting:

$d = date("F dS, Y", $h) ;
$w= date("l", $h) ;

Finally you tell the user what day of the week their event falls on simply using Echo():

Echo "$d is on a $w";

So the full code will look like this:

<?php
$h = mktime(0, 0, 0, 10, 31, 2008);
$d = date("F dS, Y", $h) ;
$w= date("l", $h) ;
Echo "$d is on a $w";
?>

The code above will return: October 31st, 2008 is on a Friday

More PHP / MySQL Quick Tips
Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Step By Steps
  5. PHP Day of the Week - Find what day of the week events fall on using PHP

©2009 About.com, a part of The New York Times Company.

All rights reserved.