How would you convert a date string that might be formatted like:
m/d/yyyy H:i:s or mm/dd/yyyy H:i:s
and format it like:
yyyy-mm-dd H:i:s
I can format either of the two inputs into my desired format, but not both.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
strtotime()will have no problem parsing these two datetime formats.Then just use its return unix timestamp integer with
date()to generate the desired format string.