Change date format from sysdate() to D-M-Y


I am storing date of new inserted records in mysql date columns “created_date”

I am using sysdate() function to store date and it is working.

Following is the date stored in “created_date” column.

9/18/2013 12:00:00 AM

I want to show date on webpage in D-M-Y format but by default it is coming in Y-M-D format. (2013-09-18)

How to change format D-M-Y to Y-M-D

Any idea?


There is plenty of documentation in the php manual on converting dates. Search for ‘date’

Create a datetime object and use the format method, its simple:

$time = sysdate();
$date = new DateTime($time);
$formatDate = $date->format('Y-M-D');

mission completed.