PHP 01/01/1970 日期字段的问题


PHP 01/01/1970 Issues with Date Fields

我正在从字符串中提取日期。下面是我的代码。我最后会only January 1, 1970。请帮我解决这个问题。您的帮助将不胜感激。

    $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('/', '-', $date));
     }
     echo $newDate = date("F j, Y",$newDateM);
    }else{$newDate = '';}
    // print this date only January 1, 1970 i want this date 23/03/1951

使用以下代码

$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('/', '-', $date));
}
   echo $newDateM = date("m/d/Y",$timestamp);
   echo $newDate = date("F j, Y",$timestamp);
}else{$newDate = '';}