I need to convert Oct 24, 2011 03:16 PM to 2011-10-24 15:16:00 in php.
I know its possible by creating a variable for each month “$jan = 01, $feb = 02, etc” and then using “explode” to split the information by space and re-arranging it in the correct order.
But is there any simpler way to do it?
The function
strtotime()is a very powerful date parser. Use it to get a UNIX timestamp of the incoming date, and use thedate()function to output the date in your desired format.