woo*_*586 9 php date strtotime
可能重复:
获取PHP中的第一天?
给定时间戳我需要找到时间戳所属的第一天.
例如
$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);
Run Code Online (Sandbox Code Playgroud)
一周的开始应该等于2011-06-27,此时它已经出现了可怕的错误,并且等于1970-01-01,这表明我的"一周的第一天"格式无效.
任何想法将非常感谢,谢谢,
小智 12
$time = strtotime("2011-07-01 00:00:00");
$weekStartDate = date('Y-m-d',strtotime("last Monday", $time));
Run Code Online (Sandbox Code Playgroud)