cakephpcakephp-3.0

cakephp 3 displaying date without time


CakePHP 3: I have a database field which is a DATE (not DATETIME nor TIMESTAMP)

When I display

echo $contact->date;

It will show something like 2014. 01. 06. 0:00. How to hide hours and minutes?

I tried

print $this->Time->format($contact->date, 'Y-m-d');

but I got 2014-0-6

How to get year-month-day?

rrd


Solution

  • Have you tried this?

    echo $contact->date->format('Y-m-d');