IT & Programming

Get day of week from a date

Function accepts date as parameter and return day of the week.

Function

function getWeekDay($date) {

    $month = date('m', strtotime($date));
    $day = date('d', strtotime($date));
    $year = date('Y', strtotime($date));

    return date('l', mktime(0, 0, 0, $month, $day, $year));
}

Calling The Function

echo getWeekDay('2010-11-24');

Output

Wednesday

Leave A comment

Email address is optional and will not be published. Only add email address if you want a reply from blog author.
Please fill required fields marked with *