Skip to main content
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
If I have a $db 'Date' => 'Date' and then in getCMSFields() I have new DateField('Date'), it shows the date and time. I want it to only show the date because there is no time needed.
Note: I just noticed that the Database field type was datetime so I changed it to date and that fixed the issue.
But still sometimes you want to store date in datetime format, but in one situation only display them in DD-MM-YYYY and in another situation in DD-MM-YYYY HH:MM.
I couldn't find any SS build in solution, so I think creating a method in your controller will fix the issue:
$datetime = new DateTime($this->YourDateTimeField); // >= php 5.2
return $datetime->format('jS, F Y'); // or d-m-Y