看看strtotime能做什么:
<?php
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
?>
(取自官方PHP 手册)。
在你的情况下:
$renewalDate = date('d F Y', strtotime($rows['CoverStartDate']));
$desiredDate = date('d F Y', strtotime("{$renewalDate} + 1 year - 1 day"));
echo $date;
我自己试过的例子是:
$date = date("d F Y");
$date = strtotime("{$date} + 1 year - 1 day");
$date = date("d F Y",$date);
echo $date;
并输出 2014 年 9 月 3 日,这是正确的。
希望这可以帮助!