$n = 2;//这个取值可以随意改变
$t = strtotime("-{$n} days");//相比于当前时间戳减去 $n*86400 s的时间
$t = strtotime("-{$n} days 00:00:00");//当前日期的前n天的0点
$t = strtotime("-{$n} days 23:00:00");//当前日期的前n天的23点
$n = 2;//这个取值可以随意改变
$t = strtotime("+{$n} days");//相比于当前时间戳加上 $n*86400 s的时间
$t = strtotime("+{$n} days 00:00:00");//当前日期的后n天的0点
$t = strtotime("+{$n} days 23:00:00");//当前日期的后n天的23点
$n = 2;//这个取值可以随意改变
$date = "2015-02-27";
$t = strtotime("+{$n} days {$date}");//相比于当前时间戳加上 $n*86400 s的时间
$t = strtotime("+{$n} days {$data} 00:00:00");//当前日期的后n天的0点
$t = strtotime("+{$n} days {$data} 23:00:00");//当前日期的后n天的23点
$t = strtotime("yesterday");
$t = strtotime("yesterday midnight");
$t = strtotime("yesterday 00:00:00");
//以上三个结果一样,但是为了严谨期间,如果需要时分秒,给出精确时间
$t = strtotime("tomorrow");
$t = strtotime("tomorrow midnight");
$t = strtotime("tomorrow 00:00:00");
$year = 2015;
$month = 2;
$t = strtotime("first day of {$year}-{$month}");//指定月份的第一天
$t = strtotime("first day of {$year}-{$month} 11:00:00");//指定月份的第一天11点
$t = strtotime("last day of {$year}-{$month} 11:00:00");//指定月份的最后一天
$t = strtotime("last day of {$year}-{$month} 11:00:00");//指定月份的最后一天11点
以上仅仅是一小部分
ps
使用 +|- days[month|year] month和year可能出现的结果不是预期结果,慎用
-ago 从当前时间往前计算
要想处理时间快,请认准 strtotime(str,timestamp)