I am working in cakephp 3 and I want to print my time object in Y-m-d format.
This is my object
'expiry' => object(Cake\I18n\Time) {
'time' => '2015-07-31T00:00:00+0000',
'timezone' => 'UTC',
'fixedNowTime' => false
},
Can anyone help me with this?
In Cakephp 3.* you use the
Time::i18nFormat()
method. It worked for meEdit:
I looked through the 3.3 docs and found this good example. There are constants you can use to format dates for common use cases like
Time::UNIX_TIMESTAMP_FORMAT
,\IntlDateFormatter::FULL
CakePHP documentation
Edit 2:
Also look at the time helper class
You can reference it in views like so:
$this->Time->format($format);
$object->created->format('Y-m-d')
get result where dt_updated is less than current date.
I did it. All I had to do was use the Time helper in my view.
$this->Time->format($user->expiry,'Y-M-d')
.