DaveE
DaveE

Reputation: 1643

Convert a mysql date (datetime) into a better date format using php

I some php code which gets info from a mysql database. The problem is that the date is coming out in the format : "2010-02-03 22:21:26"

Does anyone know a simple solution to make the date more user friendly format. e.g

2nd march 2010 at 22:21.

Upvotes: 5

Views: 3337

Answers (3)

Frank Heikens
Frank Heikens

Reputation: 127137

Or use the datetime-class.

Upvotes: 2

Dor
Dor

Reputation: 7494

See strtotime() and date()

e.g., 2010-02-03 22:21:26 to 3rd February 2010 at 22:21:

$DateTimeStr = '2010-02-03 22:21:26';
echo date('jS F Y \a\t G:i', strtotime($DateTimeStr));

Upvotes: 10

Kevin
Kevin

Reputation: 13226

date() function will assist you in this.

Something like

$date = date('j F, Y h:i:s', strtotime($date_value));
print $date;

Format options:

http://www.php.net/manual/en/function.date.php

Upvotes: 2

Related Questions