PHP code example of szymat / date-time-interval-advanced
1. Go to this page and download the library: Download szymat/date-time-interval-advanced library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
szymat / date-time-interval-advanced example snippets
// Can be also DateTime object
$date = new DateTimeImmutable('2021-05-12 13:43:10');
$interval = new Interval\Interval('-P1D|23:59:59');
$newDate = $interval->getDate($date); // Will return new object
echo $date->format('Y-m-d H:i:s') . ' => '.$newDate->format('Y-m-d H:i:s') . "\n";