Page 1 of 1

List of Date between two dates

Posted: Sat Sep 20, 2003 7:14 am
by gowni
Hi friends ,

I am new to php . Can anyone help to get list of dates between 2 dates.

Thanks in advance
gowni

Posted: Sat Sep 20, 2003 9:15 am
by volka
I prefer using the highlevel time-functions of php even if it take a bit longer. They are very flexible.
e.g.

Code: Select all

<?php
$tsStart = strtotime("15 December 2003");
$tsEnd = strtotime("+1 week", $tsStart);

$dateStart = getdate($tsStart);

do
{
	$tsCurrent = mktime(
			$dateStart['hours'], $dateStart['minutes'], $dateStart['seconds'],
			$dateStart['mon'], $dateStart['mday'], $dateStart['year']
		);
		
	echo date('D M j Y', $tsCurrent), "\n";
	
	$dateStart['mday'] += 1; // mktime takes care of day-of-month values that are out-of-bound
}while($tsCurrent < $tsEnd);
?>
take a look at the manual pages of
strtotime()
getdate()
date()
mktime()