Saturday, 25 October 2014

How to find day of week in php?

How to find day of week in php?

$timestamp = strtotime(date('2014-10-25'));
$dw = date( "w", $timestamp);// $dw will be 0 (for Sunday) through 6 (for Saturday) 
$days = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
echo "today is ".$days[$dw];

Output
today is Saturday


1 comment :

Unknown said...

You can achieve the same result with a simple one line code below:
echo date('l');

Post a Comment