Php strtotime not sum vaules


Php strtotime not sum vaules

您好,我正在使用此代码进行测试。

 <?php echo date("H:i:s", strtotime('00:00:10') + strtotime('00:00:10')); ?>

但是输出是"15:32:04"而不是"00:00:20",我找不到解决方案。

我也尝试:

<?php echo gmdate("H:i:s", strtotime('00:00:10') + strtotime('00:00:10')); ?>

并给我相同的输出。

感谢您的帮助

你应该使用 dateTime 类:http://php.net/manual/en/class.datetime.php

一旦你开始使用它,它就会简单得多,你几乎可以通过调用函数来做任何你想做的事情。 例如,您可以通过调用 Add 函数向日期对象添加 X 时间:http://php.net/manual/en/datetime.add.php

请记住,只有当您拥有 php 5.3 或更高版本时,此类才会存在。