从时间戳中的日期添加天数

时间:2014-04-11 23:06:11

标签: cakephp cakephp-2.3 caketime

我正在尝试以timestamp格式获取日期,并在其上添加5天。

$dataCriado =  $this->Solicitation->find('first', array('conditions' => array('id' => $id), 'fields' => array('data')));
 $prazo = CakeTime::format($dataCriado['Solicitation']['data'], '+ 5 days');
在本书中我只看到了从当前日期添加天数的功能。但我需要在过去的日期添加。 感谢

1 个答案:

答案 0 :(得分:2)

如果CakeTime像我怀疑的那样工作,你也可以给它日期加相对时间如下:

CakeTime::format('2014-11-04 16:00:00 + 5 days');

请参阅有关PHP的strtotime()https://php.net/manual/en/function.strtotime.php和日期时间格式https://php.net/manual/en/datetime.formats.php的信息,以了解所有可以作为第一个参数传递给CakeTime :: format()的内容。

相关问题