Php strftime添加+;1天也可以减少5分钟
不知何故,使用strotime并添加“+1天”不仅可以增加一天,还可以减少5分钟 在下面的示例中,我期望“2013-10-02 08:15:00”,但得到“2013-10-02 08:10:00”:Php strftime添加+;1天也可以减少5分钟,php,date,datetime,time,strtotime,Php,Date,Datetime,Time,Strtotime,不知何故,使用strotime并添加“+1天”不仅可以增加一天,还可以减少5分钟 在下面的示例中,我期望“2013-10-02 08:15:00”,但得到“2013-10-02 08:10:00”: $myDate = '2013-10-01 08:15:00'; $newDate = strtotime($myDate . ' +1 day'); $newDate = strftime("%Y-%m-%d %H:%m:00", $newDate); debug($newDate); //'2
$myDate = '2013-10-01 08:15:00';
$newDate = strtotime($myDate . ' +1 day');
$newDate = strftime("%Y-%m-%d %H:%m:00", $newDate);
debug($newDate);
//'2013-10-02 08:10:00'
但是-如果我使用date()
而不是strftime()
,它可以正常工作
$myDate = '2013-10-01 08:15:00';
$newDate = strtotime($myDate . ' +1 day');
$newDate = date("Y-m-d H:i:s", $newDate);
debug($newDate);
//'2013-10-02 08:15:00'
需要一个大写的M而不是M 检查
仅在您的系统上。肯定还有其他问题,这不是完整的代码,是吗?Woops说得太快了。发生在strftime函数lol%m表示月份而不是分钟@Prashank-你是对的-我以为这两个函数都不起作用,但它只是w/
strftime
。这至少有帮助——我有一个解决办法。仍然会接受任何解释为什么或者如何使用strftime的答案。瞧,有时候这是最愚蠢的小事:)谢谢。
$myDate = '2013-10-01 08:15:00';
$newDate = strtotime($myDate . ' +1 day');
$newDate = strftime("%Y-%m-%d %H:%M:00", $newDate);
debug($newDate);