-4

我们如何计算过去 3 个月的天数?

即 - 今天是11-11-2013

我想计算从1st September到的总天数today;即72天。

11 月 1 日将自动更改。

4

5 回答 5

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 "; 
于 2013-11-11T10:04:59.773 回答
1
<?php

     $now = time(); // or your date as well
     $your_date = strtotime("2010-01-01");
     $datediff = $now - $your_date;
     echo floor($datediff/(60*60*24));

?>

您也可以查看此链接

于 2013-11-11T09:41:14.323 回答
0

尝试这个:

date('d') + cal_days_in_month(CAL_GREGORIAN, date('m') -1 , date('y')) + cal_days_in_month(CAL_GREGORIAN, date('m') -2 , date('y'));
于 2013-11-11T09:41:20.603 回答
-1
$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);
于 2013-11-11T10:00:20.063 回答
-1
$today  =   strtotime("+1 day");
$beforeThreeMonth   =   date("M-Y",strtotime("-2 month"));
$beforeThreeMonthDate   =   strtotime($beforeThreeMonth);

$timeStampInterval  =   $today-$beforeThreeMonthDate;

echo floor($timeStampInterval/(60*60*24));
于 2013-11-11T10:15:46.080 回答