php strotime返回1970-01-01

php strotime返回1970-01-01,php,Php,您已经通过了24小时制的AM。我已经纠正了它 <?php $a = 'MAY 05, 2001 00:54:00 AM'; echo date('Y-m-d',strtotime($a)).'<br />'; $b = 'MAY 05, 2001 05:54:00 AM'; echo date('Y-m-d',strtotime($b)).'<br />'; //MAY 05, 2001 00:54:00 AM return 1970-01-01 //

您已经通过了24小时制的AM。我已经纠正了它

<?php
$a = 'MAY 05, 2001  00:54:00 AM';

echo date('Y-m-d',strtotime($a)).'<br />';

$b = 'MAY 05, 2001  05:54:00 AM';

echo date('Y-m-d',strtotime($b)).'<br />';

//MAY 05, 2001  00:54:00 AM return 1970-01-01
//MAY 05, 2001  05:54:00 AM return 2001-05-05

?>
$a='2001年5月5日00:54:00';
回显日期('Y-m-d',标准时间($a))。
; $b=‘2001年5月5日05:54:00 AM’; 回显日期('Y-m-d',标准时间($b))。

调幅
AM
表示您正在使用一个。但是,此时钟系统中没有“零小时”,因此您的第一个
00:54:00 AM
时间示例不是有效时间(12小时时钟从1运行到12,然后在切换AM/pm的情况下翻转回1)。也许您的意思是
00:54:00
(24小时制)或
12:54:00 AM/PM
(一点前六分钟)。

如果您使用的PHP版本高于5.3.0,您可以使用

$a='2001年5月5日00:54:00';
回显日期('Y-m-d',从格式(“F d,Y H:i:s,$a”)中解析日期)。

那么,您想做什么。。你没有告诉我你到底需要什么,你想在这里显示小时/分/秒吗。。您显示的代码运行良好。。错误的是很多时间是12小时制需要转换成24小时制,正如你看到的2013年8月22日03:60:00下午返回2013-08-09 20:13:00这工作正常,但2013年8月29日04:60:00下午返回1970-01-01 00:00:00。。。告诉我;你有没有在闹钟上看到“04:60”?如果是这样的话,它就坏了。不是这样:@miket:那些日期也是无效的,因为没有所谓的六十分钟。
04:59:00
之后的分钟是
05:00:00
,而不是
04:60:00
。一些非常宽松的日期/时间解析器可能会接受像您提供的示例这样的古怪格式,但很自然,它会被拒绝。
$a = 'MAY 05, 2001 00:54:00';

echo date('Y-m-d',strtotime($a)).'<br />';

$b = 'MAY 05, 2001  05:54:00 AM';

echo date('Y-m-d',strtotime($b)).'<br />';
$a = 'MAY 05, 2001 00:54:00';

echo date('Y-m-d',date_parse_from_format("F d, Y H:i:s",$a)).'<br />';