IT & Programming

Get month name from week number

Function accepts integer year and integer week as parameter and returns name of the month.

Function

function getMonthFromWeek($year, $week) {

    return date("F", strtotime("+$week week", mktime(0, 0, 0, 1, 1, $year)));
}

Calling The Function

echo getMonthFromWeek(2010,10);

Output

March

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 *