23472 Posts in 18941 Topics by 2878 members
|Go to End|
30 August 2009 at 11:59am Last edited: 30 August 2009 12:02pm
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.
30 August 2009 at 1:32pm Last edited: 30 August 2009 1:36pm
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
|Go to Top|