In this post i want to explain how to calculate the list of dates between two dates using php code. Just we have to give the starting date and ending date and this function will calculate the dates including leap year and monthly days … It will be mainly useful in the calculate the statistics or register users between given dates.

How to calculate the list of dates between two dates | Anil Labs
PHP Code:
<?php
$fromDate = "02/14/1983"; // month / day / year
$toDate = "06/07/2011"; // month / day / year
$dateMonthYearArr = array();
$fromDateSTR = strtotime($fromDate);
$toDateSTR = strtotime($toDate);
for ($currentDateSTR = $fromDateSTR; $currentDateSTR <= $toDateSTR; $currentDateSTR += (60 * 60 * 24)) {
// use date() and $currentDateSTR to format the dates in between
$currentDateStr = date("Y-m-d",$currentDateSTR);
$dateMonthYearArr[] = $currentDateStr;
//print $currentDateStr."<br />";
}
print_r($dateMonthYearArr);
?>
$fromDate = "02/14/1983"; // month / day / year
$toDate = "06/07/2011"; // month / day / year
$dateMonthYearArr = array();
$fromDateSTR = strtotime($fromDate);
$toDateSTR = strtotime($toDate);
for ($currentDateSTR = $fromDateSTR; $currentDateSTR <= $toDateSTR; $currentDateSTR += (60 * 60 * 24)) {
// use date() and $currentDateSTR to format the dates in between
$currentDateStr = date("Y-m-d",$currentDateSTR);
$dateMonthYearArr[] = $currentDateStr;
//print $currentDateStr."<br />";
}
print_r($dateMonthYearArr);
?>
Hope this will be useful.
Very nice tip. Blog template menus so cool
@srinu thank you.
Pingback : How to calculate statistics in daily, weekly , monthly and yearly using php - Anil Labs
its is the list from to two dates in array..
how to calculate the no.of.days??
Pingback : How to calculate statistics in daily – LIMAS