我们如何计算过去 3 个月的天数?
即 - 今天是11-11-2013
我想计算从1st September
到的总天数today
;即72天。
11 月 1 日将自动更改。
确切的时间试试这个
$datetime1 = new DateTime('2013-09-01 12:00:00');
$datetime2 = new DateTime('2013-11-11 12:00:00');
$interval = $datetime1->diff($datetime2);
echo $interval->m . " Month " .$interval->d ." Days ". $interval->h . " Hours, " . $interval->i." Mintues, ".$interval->s." seconds ";
<?php
$now = time(); // or your date as well
$your_date = strtotime("2010-01-01");
$datediff = $now - $your_date;
echo floor($datediff/(60*60*24));
?>
您也可以查看此链接。
尝试这个:
date('d') + cal_days_in_month(CAL_GREGORIAN, date('m') -1 , date('y')) + cal_days_in_month(CAL_GREGORIAN, date('m') -2 , date('y'));
$currentDate = mktime(0, 0, 0 , date("m"), date("d"), date("Y"));<br/>
$last3Months = mktime(0, 0, 0, date("m") - 3, date("d"), date("Y"));<br/>
$diff = $currentDate - $last3Months;<br/>
echo $diff/(60*60*24);
$today = strtotime("+1 day");
$beforeThreeMonth = date("M-Y",strtotime("-2 month"));
$beforeThreeMonthDate = strtotime($beforeThreeMonth);
$timeStampInterval = $today-$beforeThreeMonthDate;
echo floor($timeStampInterval/(60*60*24));