Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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?
strtotime
you should include it inside a string, not a continuous series of dividing numbers
date("Y-m-d", strtotime("31/01/2013"));
Add a comment
This will work
$date = str_replace("/", "-", "31/01/2013"); echo date("Y-m-d", strtotime($date));
Try this
$date = "31/01/2013"; $date = date("Y-m-d", strtotime($date));
Hope it will help
$date = "01/08/2013"; echo date('Y-m-d', $date);
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
strtotimeexpects a string - not a number.