MrAnt

Rumblings from a tired mind

Contact

PHP – List a range of dates

This will display ten dates starting from yesterday. The words Yesterday and Today will be added to the relevant dates.

$now = time() - 60*60*24;
echo '<ul>';
for ($i=0; $i<10; $i++) {
	echo '<li>';
	if ($i==0) {echo 'Yesterday ';}
	if ($i==1) {echo 'Today ';}
	echo date('l j F Y', $now);
	echo '</li>';
	$now += 60*60*24;
}
echo '</ul>';

Date Format
l – Monday to Sunday
j – Day of Month – 1-31
F – Month Name – January to December
Y – Full Year – 2010