tags:

views:

29

answers:

3

Hi,

How to convert 2010-07-28 00:00:00 to July 28, 2010, 00:00:00 using PHP

Thanks in advance

A: 
$date = new DateTime('2010-07-28 00:00:00');
echo $date->format('F j, Y, H:i:s');
Daniel Egeberg
@@Daniel: what does format mean here
Fero
@Fero: It formats the DateTime object as a string. See http://php.net/datetime.format
Daniel Egeberg
@@Daniel: My version is 5.2.6. It doesn't support format. In this case what shall i do
Fero
@Faro: It was added in 5.2.0.
Daniel Egeberg
thanks for the answer daniel
Fero
+1  A: 
echo date("F j, Y, H:i:s",strtotime('2010-07-28 00:00:00'));
dejavu
A: 

Use date and strtotime functions:

$date = date("F d, Y, H:i:s",strtotime('2010-07-28 00:00:00'));
echo $date;

Output:

July 28, 2010, 00:00:00
Sarfraz