php中计算时间差的方法,PHP简单计算两个时间差的方法示例

远昔 代码记录 2022-07-19 4223 0

PHP计算两个时间差的方法

$startdate="2010-12-11 11:40:00";
$enddate="2012-12-12 11:45:09";
$date=floor((strtotime($enddate)-strtotime($startdate))/86400);
$hour=floor((strtotime($enddate)-strtotime($startdate))/86400/3600);
$minute=floor((strtotime($enddate)-strtotime($startdate))/86400/60);
$second=floor((strtotime($enddate)-strtotime($startdate))/86400/60);
echo $date."天";
echo $hour."小时";
echo $minute."分钟";
echo $second."秒";
运行结果:
732天
0小时
12分钟
12秒

评论

发表评论:

挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
提交评论

清空信息
关闭评论