$date1 = new DateTime('2021-05-01'); $date2 = new DateTime('2021-06-01'); $interval = $date1->diff($date2); echo $interval->format('%R%a days');
$ny_time = new DateTimeZone('America/New_York'); $now = new DateTime(null, $ny_time); echo $now->format('Y-m-d H:i:s');
$date = new DateTime('2021-06-01'); $interval = new DateInterval('P10D'); $date->add($interval); echo $date->format('Y-m-d');This adds 10 days to the given date, and outputs the result as "2021-06-11". All of these classes are part of the core PHP library, and do not require any external package library.