Home > Backend Development > PHP Tutorial > 时间计算的问题

时间计算的问题

WBOY
Release: 2016-06-23 13:48:32
Original
851 people have browsed it

请问这样的时间格式怎么计算他们的时间差
2014-09-22T15:53:20Z
2014-09-22T13:53:20Z


回复讨论(解决方案)

T和Z是什么意思

不知道,这个格式是要求这样的,是格林威治标准时

T和Z是XML schema 的日期类型   Z表示用UTC时间  +8小时就是北京时间 

计算时间差
$ret = strtotime('2014-09-22T15:53:20Z')-strtotime('2014-09-22T13:53:20Z');//本来都需要减8小时
var_dump($ret);

就一个函数调用问题
strtotime

转化成时间戳去进行计算妥妥的

$atime = '2014-09-22T15:53:20Z';$btime = '2014-09-22T13:53:20Z ';$time = strtotime($atime) - strtotime($btime);echo $time/60/60;
Copy after login

转化成时间戳再比较

echo gmdate('H:i:s', strtotime('2014-09-22T15:53:20Z') - strtotime('2014-09-22T13:53:20Z'));
Copy after login
02:00:00

PHP日期处理详解 http://www.phpthinking.com/archives/330

都转化成时间戳,在比较

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template