I wanted to get the day of week from a string date in PHP and was running into some problems. It seems that you cant just get the day of week by passing the date string to the date() function like,
$dayOfWeek = date( “w”, ‘2011-12-25’);
This would give an error. What you have to do is to convert the date string to a unix time object and then pass that value to the date() function to get the day of week. like,
$date = strtotime(‘2011-12-25’);
$dayOfWeek = date(“w”, $date);
this would give the day of week as a number with Sunday => 0, Monday => 1 … till Saturday => 6.
Small thing but lots of headache. 🙂
resources to check out,