[Solved] PHP 01/01/1970 Issues with Date Fields


Use below code

$current="DATE OF : 23/03/1951 BENCH:";

$DATEOF = preg_replace('/(.*)DATE OF (.*?)BENCH:(.*)/s', '$2', $current);

if (!is_null($DATEOF)) {
$oldDate = $DATEOF;
$oldDateReplace = str_replace(array('!\s+!', '/^\s+/', '/\s+$/',':'), array('','','',''), trim($oldDate));

$date="".$oldDateReplace.'';
$timestamp = strtotime($date);
if ($timestamp === FALSE) {
     $timestamp = strtotime(str_replace("https://stackoverflow.com/", '-', $date));
}
   echo $newDateM = date("m/d/Y",$timestamp);
   echo $newDate = date("F j, Y",$timestamp);

}else{$newDate="";}

5

solved PHP 01/01/1970 Issues with Date Fields