1
我需要从一个起点获得26个日期。下一个日期从前一个日期开始。这将是疯狂的硬编码的一切...所以我想知道如何动态地做到这一点?有更聪明的方法吗?我期待在第二次约会后增加。也许有一个for循环?如何使用strtotime动态增加日期?
<?php
//incrementing dates for bi-weekly (26 periods// 26 dates)
$firstdate = strtotime("+17 days", strtotime("2017-04-03"));//1
$i = date("Y-m-d", $firstdate); echo date("Y-m-d", $firstdate);//echo for testing
echo'<br>';
$seconddate =strtotime("+14 days", strtotime($i));//2
$ii = date("Y-m-d", $seconddate); echo date("Y-m-d", $seconddate);//echo for testing
echo'<br>';
?>
尝试和标签这与语言首先最简单的方法,经过那么多深奥的东西。 – tadman
你想通过增加日期的数量是多少?这是一个恒定的金额还是一个变化的金额? – Jpsh
@ user3299379:在第二次约会之后,它总是会是+14天 –