<?php
$year = '2017';
$week = '2';
echo date( "F jS", strtotime($year."W".$week."0"));
?>
我没有得到我预期的结果;我想要Sun 8th
,但我得到May 15th
。
我出错了什么?
答案 0 :(得分:3)
试试这个,
$year = "2017";
$week = "02"; // Week number must be two digit
$date1 = date( "l, M jS, Y", strtotime($year."W".$week."0") ); // First day of week
echo $date1;
输出
Sunday, Jan 8th, 2017
我希望它会有所帮助。
答案 1 :(得分:0)
我想你想要第二周的第一天正确吗?那是第8天:
echo date( "D jS", mktime(0, 0, 0, 1, 8, 2017));