Question

I'm trying to get an date in timestamp format and add 5 days on it.

$dataCriado =  $this->Solicitation->find('first', array('conditions' => array('id' => $id), 'fields' => array('data')));
 $prazo = CakeTime::format($dataCriado['Solicitation']['data'], '+ 5 days');

in the book i just see functions to add days from current date. But I need to add in a past date. Thanks

Was it helpful?

Solution

If CakeTime works like I suspect it does, you can also give it dates plus relative times like so:

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

See information on PHP's strtotime() https://php.net/manual/en/function.strtotime.php and date time formats https://php.net/manual/en/datetime.formats.php for what all you can pass into CakeTime::format() as the first argument.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top