利用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)

相关文章:

  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
猜你喜欢
  • 2021-06-15
  • 2021-06-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-11
  • 2022-12-23
相关资源
相似解决方案