PHP 日期始终返回为 1970 年 1 月 1 日,并且 strftime 不翻译


PHP date is always being returned as 01 January 1970 and strftime not translating

好的,有很多关于这个问题的问题,我尝试了我在那里找到的大多数解决方案,但没有成功。

我有一个表单将这种格式的日期传递给 PHP 函数:26/11/2014

在函数中,我必须将其转换为其他形式,这是我的代码:

$date_1 = date('d F Y', strtotime($_REQUEST['date']));
setlocale (LC_TIME, 'de_DE');
$date_transl = strftime('%d %B %Y', strtotime($_REQUEST['date']));

在这两种情况下,我都返回了01 January 1970所以我面临 2 个问题:

1) 返回的日期错误

2) strftime没有翻译日期

/字符替换为 -,它将完成工作:

$_REQUEST['date'] = str_replace('/','-',$_REQUEST['date']);
$date_1 = date('d F Y', strtotime($_REQUEST['date']));
setlocale (LC_TIME, 'de_DE');
$date_transl = strftime('%d %B %Y', strtotime($_REQUEST['date']));

试试

$date_1 = date('d F Y', strtotime(str_replace('/','-','26/11/2014')));