//$startdate是开始时间,$enddate是结束时间
<?php
$startdate="2011-3-15 11:50:00";
 
$enddate="2012-12-12 12:12:12";
 
$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."秒";
?>

  

date("Y-m-d H:i:s");  //24小时
date("Y-m-d h:i:s");  //12小时
date("Y-m-d h:i:sa"); //小时am或pm

  

相关文章:

  • 2022-02-07
  • 2021-05-23
  • 2021-08-17
  • 2022-02-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
  • 2021-04-18
  • 2022-01-13
相关资源
相似解决方案