Home > php教程 > PHP源码 > PHP获取两个时间相差的年数、月数和天数

PHP获取两个时间相差的年数、月数和天数

PHP中文网
Release: 2016-05-25 17:03:10
Original
1699 people have browsed it

1. [代码][PHP]代码    

<?php
  //Get detail gap of year,month and days between two different time by vfhky 20130728
  $common = (time()-strtotime(get_option(&#39;swt_builddate&#39;)));
  $a = floor($common/86400/360);	//整数年
  $b = floor($common/86400/30) - $a*12;	//整数月
  $c = floor($common/86400) - $a*360 - $b*30;	//整数日
  $d = floor($common/86400);	//总的天数
  echo $a."年".$b."月".$c."日(共计".$d."天)";
?>
Copy after login

                   

                   

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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template