如何查找给定日期所属一周的第一天?
可能的重复:
用 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);
一周的开始应该等于 2011-06-27,此时它出了严重的错误,等于 1970-01-01,这对我来说意味着“一周的第一天”格式是无效的。
任何想法将不胜感激,谢谢,
Possible Duplicate:
Get first day of week in PHP?
Given a timestamp I need to find the first day the week the timestamp belongs to.
e.g.
$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);
The week start should equal 2011-06-27 at the moment its gone horribly wrong and equals 1970-01-01 which suggests to me the “first day of week” format is invalid.
Any ideas would be much appreciated thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
测试一下:
Test it :