当我这么做时:
$date = "2017-02-06 21:30:00";
$end_date = "2017-02-28 21:30:00";
while (strtotime($date) <= strtotime($end_date)) {
echo $date."<br />";
$date = date("Y-m-d h:i:s", strtotime("+7 day", strtotime($date)));
}我得到了这个输出:
2017-02-06 21:30:00
2017-02-13 09:30:00
2017-02-20 09:30:00
2017-02-27 09:30:00你知道为什么+7天比12小时短吗?
发布于 2017-02-01 15:48:41
有区别的
有关它的更多信息:http://php.net/manual/en/function.date.php
您的代码应该是:
$date = "2017-02-06 21:30:00";
$end_date = "2017-02-28 21:30:00";
while (strtotime($date) <= strtotime($end_date)) {
echo $date."<br />";
$date = date("Y-m-d H:i:s", strtotime("+7 day", strtotime($date)));
}发布于 2017-02-01 15:48:51
不是,你用的是:
date("Y-m-d h:i:s",$time); // as h stands for 12-hour format of an hour with leading zeros 01 through 12用H代替:
date("Y-m-d H:i:s",$time); // as H stands for 24-hour format of an hour with leading zeros 00 through 23https://stackoverflow.com/questions/41983869
复制相似问题