Get next seven days list from Today using PHP

A PHP function that helps to get list of next days form current day. There are many way but I created one of best solution using  foreach and strtotime in-built PHP functions.

<?php
$how_many_days=6; /* Number of next days what you need to list */ 

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

?>

The above code returns result as following format:
MON 20
TUE 21
WED 22
THU 23
FRI 24
SAT 25
SUN 26

The list would then automatically regenerate itself every day, so that on the next day it would start on TUE 21 and go till MON 27.

By Ashutosh Pratap

I am software developer by profession and doing work and research in field of Computer programmings like PHP, WordPress, Magento, jQuery, Google APIs and many more web languages. Apart from this I write blogs on programming languages like PHP, Javascript, WordPress etc. I am also individual and independent Freelancer so you can hire me for your web work.

Leave a comment

Your email address will not be published. Required fields are marked *