如果在PHP中同时具有年份和周# (ISO-8601年的周数),那么如何获得日期?


If I have both the year and the week # (ISO-8601 week number of year) in PHP, how do I get a date?

例如,如果我有year = 2014和week # = 22,我如何从中得到YYYY-mm-dd日期?

使用strtotime(),

$year = 2014; 
$week = 9; 
$date = strtotime($year."W".substr("0".$week, -2));
// e.g. strtotime("2014W09")
echo date("Y-m-d",$date);
输出:

2014-02-24