Creating List of Next Seven Days

I am working on an events site where I want to list the next seven days, and then show any events occurring on those days underneath. But, I am getting puzzled by the first hurdle as the whole date thing confuses the hell out of me.

All I want is a list like this:

SAT 05
SUN 06
MON 07
TUE 08
WED 09
THU 10
FRI 11

The list would then automatically regenerate itself every day, so that on the next day it would start on SUN 06 and go til SAT 12. Also bear in mind that I will be storing my dates in the format 2011-06-06 21:00:00.

I’m pretty sure this can’t be too hard to accomplish! Can anyone steer me in the right direction?


This should do it:

for($i=0; $i<=6; $i++){
	echo strtoupper(date("D d", mktime(0, 0, 0, 0, date("d")+$i, 0))."\

Much the same as Zarni Dentatrose’ reply, but this time using foreach and strtotime.

foreach( range(0,6) as $cnt ){
echo strtoupper( date('D d',strtotime( "today + $cnt day") ) ) . PHP_EOL;

With PHP 5.3 there’s also the DatePeriod class.

Here’s a snippet getting the next seven days (the examples above start from today, mine starts from tomorrow).

$days = new DatePeriod(new DateTime, new DateInterval('P1D'), 7, DatePeriod::EXCLUDE_START_DATE);
foreach ($days as $day) {
	echo strtoupper($day->format('D d')) . PHP_EOL;