0
我试图获取每一年的日期或两个日期之间的任何可变间隔。我的日期示例如下。它似乎永远运行,我不能让它工作,最终不会打印任何东西。php从现在开始每两年的日期之间每隔1年获取日期
$currentDate = '2014-04-15';
$endDate = '2018-04-15';
$reminder = '+1 year';
$dateArray = array();
while($currentDate <= $endDate){
$currentDate = date('Y-m-d', strtotime($reminder, strtotime($currentDate)));
array_push($dateArray, $currentDate);
}
print_r($dateArray);
谢谢@Andriy是的,这是一个愚蠢的错误。我改变了它,但是它仍然没有打印出任何结果。 –
尝试启用错误输出或查看日志。我在在线测试中试过了你的代码,并且它按预期工作。返回 Array([0] => 2015-04-15 [1] => 2016-04-15 [2] => 2017-04-15 [3] => 2018-04-15 [4] => 2019 -04-15) – Andriy
真棒。谢谢@Andriy和所有帮助过我的人。它会出现我没有回应$ reminderP值。 –