1. Go to this page and download the library: Download phrity/datetime 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/ */
phrity / datetime example snippets
use Phrity\DateTime\Range;
$start = new DateTime("2023-05-17 13:23");
$end = new DateTime("2023-06-20 23:23");
$now = new DateTime();
$interval = new DateInterval("P15D");
$timezone = new DateTimeZone("+02:00");
$range_1 = new Range($start, $end);
echo "$range_1"; // "2023-05-17T13:23:00+00:00 - 2023-06-20T23:23:00+00:00"
$range_2 = new Range($start, $interval);
echo "$range_2"; // "2023-05-17T13:23:00+00:00 - 2023-06-01T13:23:00+00:00"
$range_1->getTimezone(); // -> DateTimeZone
$range_1->setTimezone($timezone);
$range_1->getStart(); // -> DateTimeImmutable
$range_1->getEnd(); // -> DateTimeImmutable
$range_1->format("c"); // Format using the same options as for DateTime
$range_1->add($interval); // Adds interval on start/end of range
$range_1->sub($interval); // Subtracts interval on start/end of range
$range_1->modify("+1 month"); // Modifies start/end of range
$range_1->inRange($now); // If now is within range
$range_1->isBefore($now); // If now is before range
$range_1->isAfter($now); // If now is after range
$range_1->inRange($range_2); // If range_2 is within range_1
$range_1->isBefore($range_2); // If range_2 starts before range_1
$range_1->isAfter($range_2); // If range_2 ends after range_1
$range_1->getInterval(); // -> DateInterval, between start and end
$range_1->getPeriod($interval); // -> DatePeriod, intervals between start and end
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.