I have different types of date strings, examples are given below. How can I convert these strings in to date time in PHP. Could you please help me to solve this problem?
examples:
1: 10:12 am ETAug 31, 2009
2: August 31, 2009, 9:08 AM ET
3: Sept. 1, 2009 10:20 a.m. ET
4: 9:45 am ETSep 2, 2009
I had tried some code but the result is wrong.
<?php
date = 'Aug. 28, 2009 10:26 a.m. ET';
$remove[] = "'";
$remove[] = '.';
$remove[] = ',';
$remove[] = 'am';
$remove[] = 'ET';
$replace = str_replace($remove, '', $date);
$space[] = ' ';
$datetime = str_replace($space, '-', $replace);
echo $datetime . '<br>';
$date = date_create_from_format('F-d-Y', $datetime);
echo "Format:" . $date->format('Y-m-d') . "\n";
?>