Print every day of the previous week
$week_start = date("U",mktime(0,0,0,date("m"),date("d")-7,date("Y")));$week_end = date("U",mktime(23,59,59,date("m"),date("d")-0,date("Y")));$date=date('Y-m-d',$week_start);$date1=date('Y-m-d',$week_end);
I don't know how to write it here.
I want to use for loop writing, but I don't know how to write the conditions .. How can I print the date of each day?
Reply to discussion (solution)
This is part of my favorite articles. You can change it yourself.
Echo "today:". date ("Y-m-d ")."
";
Echo "yesterday:". date ("Y-m-d", strtotime ("-1 day ")),"
";
Echo "tomorrow:". date ("Y-m-d", strtotime ("+ 1 day "))."
";
Echo "one week later:". date ("Y-m-d", strtotime ("+ 1 week "))."
";
Echo "one week, two days, four hours, two seconds later :". date ("Y-m-d G: H: s", strtotime ("+ 1 week 2 days 4 hours 2 seconds "))."
";
Echo "next Thursday:". date ("Y-m-d", strtotime ("next Thursday "))."
";
Echo "last Monday:". date ("Y-m-d", strtotime ("last Monday "))."
";
Echo "a month ago:". date ("Y-m-d", strtotime ("last month "))."
";
Echo "one month later:". date ("Y-m-d", strtotime ("+ 1 month "))."
";
Echo "Ten years later:". date ("Y-m-d", strtotime ("+ 10 year "))."
";
$week_start = strtotime(date('Y-m-d',strtotime('-6 day')));$week_end=strtotime(date('Y-m-d',time()));for($i=$week_start; $i<=$week_end; $i+=86400){echo date('Y-m-d',$i).'
';}
2013-11-27
for($i=7; $i>=0; $i--){ echo date('Y-m-d',strtotime("-$i day")).'
';}
2013-11-27
';}?>