Reputation: 217
I have this date in php: 31/01/2013
I'm trying to convert it using the strtotime function like so
date("Y-m-d", strtotime(31/01/2013));
but it keeps displaying as 1970-01-01. Any know why this is?
Upvotes: 0
Views: 308
Reputation: 1792
This will work
$date = str_replace("/", "-", "31/01/2013");
echo date("Y-m-d", strtotime($date));
Upvotes: 3
Reputation: 1792
Try this
$date = "31/01/2013";
$date = date("Y-m-d", strtotime($date));
Hope it will help
Upvotes: 1
Reputation: 13545
you should include it inside a string, not a continuous series of dividing numbers
date("Y-m-d", strtotime("31/01/2013"));
Upvotes: 5