您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

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

2024/4/6 7:02:54发布20次查看
从某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这个变态又常用的函数?
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product