Formatting date Cake\I18n\FrozenTime in CakePHP

Format a date to "YYYY-MM-dd HH:ii:ss"

From this:

object(Cake\I18n\FrozenTime) {
'time' => '2009-12-19T00:00:00+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
}

 

In CakePHP3 or CakePHP4 Controller:

\\use Cake\I18n\Time;

CakePHP4: In  your controller or view:

​$now = FrozenTime::parse($mClass['begin_date']);
echo $now->i18nFormat('yyyy-MM-dd HH:mm:ss');

 

Cake3: In your controller or view:

$mtime = $timesheet->time_in;
$time = $mtime->i18nFormat('yyyy-MM-dd HH:mm:ss');
$day = date("d", strtotime($time));      

 

Share this Post