php 时间计算

利用strtotime函数!!!


1. 计算日期30天后可以用strtotime PHP提供了一个超级简单的方式来完成本来要几十行代码的工作
   先把某日期转换成UNIX时间戳
   $t = time();  // 当前时间戳
   $t = strtotime("+30 days", $t);  // 30天后的时间戳
   echo date("Y-m-d", $t);   // 格式化日期


2. 转换2日期的时间戳...然后相减
   $t1 = strtotime("2009-08-19");
   $t2 = strtotime("2009-08-20");
   $t = $t2 - $t1;     // 相差天数的秒
   echo (int)($t / 86400)
原文地址:https://www.cnblogs.com/zcy_soft/p/1970534.html