$m= date("m"); // Month value
$de= date("d"); //today's date
$y= date("Y"); // Year value
echo date('d-m-y:D', mktime(0,0,0,$m,($de-1),$y));
Last seven days date value we can find out by using a for loop.
Here is the output of the code. $m= date("m");
$de= date("d");
$y= date("Y");
for($i=0; $i<=15; $i++){
echo date('d-m-y:D',mktime(0,0,0,$m,($de-$i),$y));
echo "<br>";
}
for($i=0; $i<=15; $i++){
echo date('m-d-Y: D',strtotime("$i day"))."<br>";
}
Output is here
11-21-2025: Fri
11-22-2025: Sat
11-23-2025: Sun
11-24-2025: Mon
11-25-2025: Tue
11-26-2025: Wed
11-27-2025: Thu
11-28-2025: Fri
11-29-2025: Sat
11-30-2025: Sun
12-01-2025: Mon
12-02-2025: Tue
12-03-2025: Wed
12-04-2025: Thu
12-05-2025: Fri
12-06-2025: Sat
PHP Date Functions
Adding Date by using DateInterval
Displaying dropdown list to select Month Year & Date
| bhanu | 30-09-2009 |
| thank you for help.it very help | |
| siswoutomo | 28-12-2009 |
| Very good this post, thank lot of | |
| James | 21-04-2010 |
| Does this work if the date is 4th of January (for example) | |
| smo | 02-05-2010 |
| Yes this will work perfectly. Try with March 1st of 2008 also. For testing you need to change the date of your PC or server. | |
| kalpana | 15-01-2013 |
| thanks you so much.It was so helpful | |