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

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

PHP中文网
PHP中文网Original
2016-05-25 17:03:101700browse

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."天)";
?>

                   

                   

Statement:
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
Previous article:MysqPdo封装Next article:php转换数组编码方法