Posted by: prajapatinilesh | May 7, 2009

Get all dates between two dates using php code.

<?php
$fromDate = ‘01/01/2009′;
$toDate = ‘01/10/2009′;

$dateMonthYearArr = array();
$fromDateTS = strtotime($fromDate);
$toDateTS = strtotime($toDate);

for ($currentDateTS = $fromDateTS; $currentDateTS <= $toDateTS; $currentDateTS += (60 * 60 * 24)) {
// use date() and $currentDateTS to format the dates in between
$currentDateStr = date(“Y-m-d”,$currentDateTS);
$dateMonthYearArr[] = $currentDateStr;
//print $currentDateStr.”<br />”;
}

echo  “<pre>”;
print_r($dateMonthYearArr);
echo “</pre>”;
?>

Thanks,
Nilesh Prajapati.


Responses

  1. Good Work

    Thank you

  2. Very useful. Your help is appreciated.

  3. Very Thnx dear! gud wrk………….

  4. Thanks ,good coding


Leave a response

Your response:

Categories