$now=strtotime(date('Y-m-d'));
$end_time=strtotime('2020-8-1');
$timediff = $end_time-$now;
$day3= intval($timediff/86400);
得到天数28天。
通过逆反思维,得知2020-08-01与当前日期相差28天,找到当前日期
$day4=intval(28*86400);
$day5=$end_time-$day4;
$day6=date('Y-m-d',$day5);
根据上面的理论倒推,假设倒推两天也就是获取前天的时间:
//当前时间的时间戳
$now=strtotime(date('Y-m-d'));
//两天的时间戳
$data=intval(2*86400);
//当前时间减去两天的时间戳得到前天的时间戳
$data1=$now-$data;
//把前天的时间戳转换为时间日期
$day6=date('Y-m-d',$data1);
最佳答案
