84669 personnes étudient
152542 personnes étudient
20005 personnes étudient
5487 personnes étudient
7821 personnes étudient
359900 personnes étudient
3350 personnes étudient
180660 personnes étudient
48569 personnes étudient
18603 personnes étudient
40936 personnes étudient
1549 personnes étudient
1183 personnes étudient
32909 personnes étudient
从某API中获取到的时间格式是这样的2014-10-30T15:59:59.999ZPHP如何格式化它为正常的date例如Y-m-d H:i:s
2014-10-30T15:59:59.999Z
Y-m-d H:i:s
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
可以自己定义,现在都采用面向对象的方式来操作时间了,就是所谓的DateTime
有很多已经定义好的格式
DateTime implements DateTimeInterface { /* 常量 */ const string ATOM = "Y-m-d\TH:i:sP" ; const string COOKIE = "l, d-M-Y H:i:s T" ; const string ISO8601 = "Y-m-d\TH:i:sO" ; const string RFC822 = "D, d M y H:i:s O" ; const string RFC850 = "l, d-M-y H:i:s T" ; const string RFC1036 = "D, d M y H:i:s O" ; const string RFC1123 = "D, d M Y H:i:s O" ; const string RFC2822 = "D, d M Y H:i:s O" ; const string RFC3339 = "Y-m-d\TH:i:sP" ; const string RSS = "D, d M Y H:i:s O" ; const string W3C = "Y-m-d\TH:i:sP" ; …… //http://php.net/manual/zh/class.datetime.php }
上面格式化,代码如下
$date = new DateTime('2014-10-30T15:59:59.999Z'); echo $date->format('Y-m-d H:i:s');
echo(date_format(date_create('2014-10-30T15:59:59.999Z'),'Y/m/d H:i:s'));这么标准的ISO时间格式
怎么没人回复strtotime这个变态又常用的函数?
<?php echo date("Y-m-d H:i:s", strtotime("2014-10-30T15:59:59.999Z")); //输出2014-10-30 23:59:59
可以自己定义,现在都采用面向对象的方式来操作时间了,就是所谓的DateTime
有很多已经定义好的格式
上面格式化,代码如下
echo(date_format(date_create('2014-10-30T15:59:59.999Z'),'Y/m/d H:i:s'));
这么标准的ISO时间格式
怎么没人回复strtotime这个变态又常用的函数?