3v4l.org

run code in 300+ PHP versions simultaneously
<?php $startDate = "2020-02-01"; $endDate = "2020-03-11"; date_default_timezone_set("Europe/Berlin"); $diff = date_create($startDate)->diff(date_create($endDate)); $test = date_create($startDate)->add($diff)->format("Y-m-d"); echo "test: ".$test." expected: ".$endDate;
based on thQiu
Output for 7.2.0 - 7.2.31, 7.3.0 - 7.3.19, 7.4.0 - 7.4.7, 8.0.0alpha1 - alpha2
test: 2020-03-09 expected: 2020-03-11