user enters datetime in M j, g:i A format, saved in mysql format and then displayed on the form again in M j, g:i A format

a user is entering time in an input textbox which gets saved into mysql and then displayed in the input textbox again

datetime in this format:
M j, g:i A

Mar 10, 6:05 PM

want to convert
to mysql format
Y-m-d H:i:s

and then back into
M j, g:i A

how to do the two conversions
Who is Participating?
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
This should work.

$mysqldate = date("Y-m-d H:i:s", strtotime("Mar 10, 6:05 PM"));
$yourdate = date("M j, g:i A", strtotime("$mysqldate"));

Open in new window

rgb192Author Commented:
thank you for organizing dates
Dave BaldwinFixer of ProblemsCommented:
You're welcome.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.