Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

Y-m-d H:i:s

convert
2012-11-16 12:00am
2012-11-15 12:30am
2012-11-15 2:30pm
to
Y-m-d H:i:s
Avatar of Ovid Burke
Ovid Burke
Flag of Saint Vincent and the Grenadines image

echo date( 'Y-m-d H:i:s', strtotime( '2012-11-15 2:30pm' ) );

Open in new window

// your date in an array
$dates = array( '2012-11-16 12:00am', '2012-11-15 12:30am', '2012-11-15 2:30pm' );

// loop and convert
foreach( $dates as $date ) {
	echo date( 'Y-m-d H:i:s', strtotime( $date ) ) . '<br>';
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ovid Burke
Ovid Burke
Flag of Saint Vincent and the Grenadines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

I like the code sample better
and thanks for
date('c') to get the ISO-8601 datetime string.
advice