| |
|
Getting yesterday and previous days date values |
You must have seen how to get today date by using date function. By changing the date value we can get the dates of yesterday. Same way we can extend this to get date values of last 7 days. Or we can extend this to get dates between any to differences.
Let us find out the date value of yesterday.
$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.
17-05-08:Sat 16-05-08:Fri 15-05-08:Thu 14-05-08:Wed 13-05-08:Tue 12-05-08:Mon 11-05-08:Sun 10-05-08:Sat 09-05-08:Fri 08-05-08:Thu 07-05-08:Wed 06-05-08:Tue 05-05-08:Mon 04-05-08:Sun 03-05-08:Sat 02-05-08:Fri
Here is 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>";
}
| |
| Subscribe |
|
Submit your email address and receive
article and product notifications. Your email is safe with us.
|
|
|
|
|
|