arkansasonline
arkansasonline

Reputation: 163

Get Day of week for week number in php

How would I go about getting the date of say the 32 Wed of a given year. Is there an easy way to do this that I am missing?

Upvotes: 0

Views: 3004

Answers (2)

Thomas Clayson
Thomas Clayson

Reputation: 29925

echo date("d m Y", strtotime("2010-W32-3")); 

i think... :p

Edit: W32 is the week number and 3 is the day of the week (1-7)

Or maybe something more complicated like this - its a bit pointless if the above works - but was just thinking of alternatives... I don't know if it would work. :p Just for fun.

echo date("d m Y", strtotime("1-1-2010 + 32 Weeks ".date("N", "Wednesday")." Days"));

maybe, but now I'm clutching at straws ha. :)

Upvotes: 1

Sjoerd
Sjoerd

Reputation: 75588

It is worth noting, that strtotime() accepts ISO week date format (for example "2008-W27-2" is Tuesday of week 27 in 2008), so it can be easily used to get the date of a given week number.

Source

Upvotes: 4

Related Questions