String to date conversion in PHP
问题 I'd like to convert such a date '2012 30 March 9:30 pm' into this format 2012-03-30 09:30:00 What is the easiest way to do that? I need it to be working on PHP 5.2 and older, so this solution isn't of any use for me date_format('Y-m-d H:M:S',date_create_from_format('Y m F g:i A', '2012 30 March 9:30 pm')) 回答1: This will extract each component from the date and rearrange it so that strtotime() understands. Convert to any date format you want after that. Using regex is probably overkill though.