Blogger Information
Blog 14
fans 0
comment 0
visits 27734
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
得出两个时间戳的差
花式BUG_beisi
Original
883 people have browsed it

//$startdate是开始时间,$enddate是结束时间

<?php

$startdate="2018-04-13 00:00:00";

 

$enddate="2018-04-14 00:00:00";

 

$date=floor((strtotime($enddate)-strtotime($startdate))/86400);

echo "相差天数:".$date."天<br/><br/>";

 

$hour=floor((strtotime($enddate)-strtotime($startdate))%86400/3600);

echo "相差小时数:".$hour."小时<br/><br/>";

 

$minute=floor((strtotime($enddate)-strtotime($startdate))%86400/60);

echo "相差分钟数:".$minute."分钟<br/><br/>";

 

$second=floor((strtotime($enddate)-strtotime($startdate))%86400%60);

echo "相差秒数:".$second."秒";

?>


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post