利用strtotime函数!!!
1. 计算日期30天后
$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)
评论