我正在尝试制作Date Range,我已经想出了一些基本的方法。
下面是我正在尝试解决的一些问题,但我在网上找不到你应该为这些问题键入的格式:
$startDate = strtotime('first day of last month');
$endDate = strtotime('last day of last month');
$startDate = strtotime('first of last week');
$startDate = strtotime('first of this week');这些是我唯一找不到参考资料的,它们可能需要特殊的编程,而且没有strtotime参考资料。
编辑:看起来我的代码应该可以工作,但是PHP5.2中有一个bug
上个月的第一天,我使用了一种变通方法。
这是可行的:$firstDayOfLastMonth = strtotime(date('Y-m',strtotime('last month‘)
发布于 2012-04-18 00:39:41
一周内你可以使用的
strtotime('this week midnight'); // returns Monday midnight of this week
strtotime('last week midnight'); // returns Monday midnight of last week如果你想从周一开始这一周,这是可行的。上周似乎假设周一是第一天。如果您想要从周日开始的一周的时间戳,请使用以下命令:
strtotime('last week Sunday midnight'); // returns Sunday midnight of this week
strtotime('-2 weeks Sunday midnight'); // returns Sunday midnight of last weekhttps://stackoverflow.com/questions/10195166
复制相似问题