Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php strftime添加+;1天也可以减少5分钟_Php_Date_Datetime_Time_Strtotime - Fatal编程技术网

Php strftime添加+;1天也可以减少5分钟

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

不知何故,使用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);

//'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);