您好,欢迎访问一九零五行业门户网

没见过这种时间格式,如何用PHP格式化它

从某api中获取到的时间格式是这样的2014-10-30t15:59:59.999z
php如何格式化它为正常的date例如y-m-d h:i:s
回复内容: 从某api中获取到的时间格式是这样的2014-10-30t15:59:59.999z
php如何格式化它为正常的date例如y-m-d h:i:s
可以自己定义,现在都采用面向对象的方式来操作时间了,就是所谓的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这个变态又常用的函数?
其它类似信息

推荐信息