-4

How we can calculate, number of days in last 3 months?

i.e. - today is 11-11-2013

I want to calculate total number of days from 1st September to today; i.e. 72 days.

1st November wil change automatically.

Glavić
  • 42,781
  • 13
  • 77
  • 107
Warrior
  • 5,168
  • 12
  • 60
  • 87

5 Answers5

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));

?>

You can also check this link.

Veer Shrivastav
  • 5,434
  • 11
  • 53
  • 83
1

For exact time try this

$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 "; 
0

Try this:

date('d') + cal_days_in_month(CAL_GREGORIAN, date('m') -1 , date('y')) + cal_days_in_month(CAL_GREGORIAN, date('m') -2 , date('y'));
Ramesh
  • 4,223
  • 2
  • 16
  • 24
-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);
Peon
  • 7,902
  • 7
  • 59
  • 100
additionster
  • 628
  • 4
  • 14
-1
$today  =   strtotime("+1 day");
$beforeThreeMonth   =   date("M-Y",strtotime("-2 month"));
$beforeThreeMonthDate   =   strtotime($beforeThreeMonth);

$timeStampInterval  =   $today-$beforeThreeMonthDate;

echo floor($timeStampInterval/(60*60*24));
pankaj
  • 69
  • 4