【发布时间】:2011-09-26 14:30:12
【问题描述】:
给定一个时间戳,我需要找到该时间戳所属周的第一天。
例如
$format = "first day of week";
//convert to time
$time = strtotime("2011-07-01 00:00:00");
//format the time to the first day of the week
$date = strtotime($format,$time);
//Put the first day of the week into a pretty format
$weekStartDate = date("Y-m-d",$date);
本周开始应该等于 2011-06-27,此时它发生了严重错误,等于 1970-01-01,这表明“一周的第一天”格式无效。
任何想法将不胜感激,谢谢,
【问题讨论】:
-
你有没有 var_dumped 你的 strtotime 输出来看看你得到了什么?
-
谢谢Pekka,答案是另一个问题的重复,是使用“上周日”的格式
-
$format = "一周的第一天";应该是“本周的第一天”,不是吗?