To change 2009-12-09 13:32:15
to 09/12/2009
views:
37answers:
4
A:
Using the date()
method.
print date("d/m/Y", strtotime("2009-12-09 13:32:15"));
Jonathan Sampson
2009-12-18 05:50:29
A:
You can use strtotime
to get the timestamp of the first date, and date to convert it to a string using the format you want.
$timestamp = strtotime('2009-12-09 13:32:15');
echo date('d/m/Y', $timestamp);
And you'll get :
09/12/2009
Pascal MARTIN
2009-12-18 05:51:51
A:
$long_date = '2009-12-09 13:32:15';
$epoch_date = strtotime($long_date);
$short_date = date('m/d/Y', $epoch_date);
The above is not the shortest way of doing it, but having the long date as an epoch timestamp ensures that you can reuse the original long date to get other date format outputs, like if you wanted to go back and have just the time somewhere else.
Anthony
2009-12-18 05:56:47