Link to home
Start Free TrialLog in
Avatar of PeterErhard
PeterErhard

asked on

PHP Convert dates

Can someone help with the syntax to convert dates such as 06/09/2011 to 2011-09-06 please?
Avatar of Cornelia Yoder
Cornelia Yoder
Flag of United States of America image

http://us2.php.net/manual/en/function.strtotime.php

will convert the string to a unix timestamp

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

will convert a unix timestamp to whatever date format you want.
ASKER CERTIFIED SOLUTION
Avatar of Loganathan Natarajan
Loganathan Natarajan
Flag of India 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
$olddate = "06/09/2011";

$unixtimestamp = strtotime($olddate);

$newdate = date("Y-m-d",$unixtimestamp);
Try this

echo date('Y-m-d', strtotime($strng))

<?php

$date = date_create_from_format('d/m/Y', '06/09/2011');
echo date_format($date, 'Y-m-d');

?>

Open in new window

Well, since you neglected to at least thank others who tried to help you, ....

You're welcome, anyway.