21298 Posts in 5735 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 804 Views |
-
I need CMS DateField to only show date, not time.

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.
-
Re: I need CMS DateField to only show date, not time.

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:
function Nicedate(){
$datetime = new DateTime($this->YourDateTimeField); // >= php 5.2
return $datetime->format('jS, F Y'); // or d-m-Y
}
| 804 Views | ||
|
Page:
1
|
Go to Top |


