views:

60

answers:

3

Hi

i need to change the format of my date string using PHP

from : "06/16/2010"

to : "2010-06-16"

can you please help me achieve this

thanks

A: 

http://www.w3schools.com/php/php_date.asp

sh00
I can't believe someone voted it up.
Col. Shrapnel
+3  A: 
$date = "06/16/2010";
echo date('Y-m-d', strtotime($date)); // outputs 2010-06-16

Using the strtotime function.

Russell Dias
strtotime isn't exactly the most friendly function when you don't have the Y-m-d format as the original date. I've had lots of trouble doing it that way.
Raphael Caixeta
Oh, odd. I don't usually use it too often so I cant comment on it. But seems fine for the problem at hand.
Russell Dias
A: 

php -r 'echo date("Y-m-d", strtotime("06/16/2010"));'

Friedrich