Hi,
I want to find the weekday from a given month, date and year. If my input is May 11, 2008 then my output will be Monday. Is there any way to get it using PHP ? Please help.
Thank you so much in advance.
Printable View
Hi,
I want to find the weekday from a given month, date and year. If my input is May 11, 2008 then my output will be Monday. Is there any way to get it using PHP ? Please help.
Thank you so much in advance.
Give this a shot.
PHP Code:$DayOfWeek = date("l", parsedate("11/05/2008"));
echo $DayOfWeek; //Returns Sunday
function parsedate($value)
{
// If it looks like a UK date dd/mm/yy, reformat to US date mm/dd/yy so strtotime can parse it.
$reformatted = preg_replace("/^\s*([0-9]{1,2})[\/\. -]+([0-9]{1,2})[\/\. -]+([0-9]{1,4})/", "\\2/\\1/\\3", $value);
return strtotime($reformatted);
}