1

add()の機能をサポートしていない古いバージョンの PHP を使用するサーバーにプロジェクトをアップロードしていますDateTime

したがって、このコード:

$tomorrow = $today->add(new DateInterval("P1D"));

サーバー ログに次のエラーが記録されます。

 PHP Fatal error:  Call to undefined method DateTime::add()

関係する解決策を見つけようとしましたが、strtotimeエラーが発生し続けます。使用できる簡単な回避策はありますか?

4

2 に答える 2

1
//Create array with all dates within date span
$begin = new DateTime( $start_date );
$end = new DateTime(date("Y-m-d",strtotime("+1 day", strtotime($end_date))));
while($begin < $end) {
    $period[] = $begin->format('Y-m-d');
    $begin->modify('+1 day');
}
于 2013-10-03T08:38:26.733 に答える