简体   繁体   English

如果我在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日期?

Use strtotime() , 使用strtotime()

$year = 2014; 
$week = 9; 

$date = strtotime($year."W".substr("0".$week, -2));
// e.g. strtotime("2014W09")

echo date("Y-m-d",$date);

Output: 输出:

2014-02-24

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM