$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);
这是我看到别人收藏的文章中的一部分。你自己去变通一下
echo "今天:".date("Y-m-d")."
";
echo "昨天:".date("Y-m-d",strtotime("-1 day")), "
";
echo "明天:".date("Y-m-d",strtotime("+1 day")). "
";
echo "一周后:".date("Y-m-d",strtotime("+1 week")). "
";
echo "一周零两天四小时两秒后:".date("Y-m-d G:H:s",strtotime("+1 week 2 days 4 hours 2 seconds")). "
";
echo "下个星期四:".date("Y-m-d",strtotime("next Thursday")). "
";
echo "上个周一:".date("Y-m-d",strtotime("last Monday"))."
";
echo "一个月前:".date("Y-m-d",strtotime("last month"))."
";
echo "一个月后:".date("Y-m-d",strtotime("+1 month"))."
";
echo "十年后:".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).'<br>'; }
for($i=7; $i>=0; $i--){ echo date('Y-m-d',strtotime("-$i day")).'<br>';}
<?php//上个礼拜一$n = strtotime("last week");$timestrap = 86400;for ($i=0; $i<7; $i++){ echo date('Y-m-d', $n+($i*$timestrap)),'<br />';}?>