1. Go to this page and download the library: Download midnight/calendrics 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/ */
midnight / calendrics example snippets
alendrics\Duration;
use Calendrics\PlainDate;
use Calendrics\PlainTime;
$invoiceDate = PlainDate::parse('2026-03-20');
$dueDate = $invoiceDate->add(new Duration(days: 14));
// A calendar date needs a time and zone to identify an instant.
$deadline = $dueDate->toZonedDateTime('Europe/Vienna', new PlainTime(17));
echo $invoiceDate, PHP_EOL; // 2026-03-20 (unchanged)
echo $dueDate, PHP_EOL; // 2026-04-03
echo $deadline, PHP_EOL; // 2026-04-03T17:00:00+02:00[Europe/Vienna]
echo $deadline->toInstant(), PHP_EOL; // 2026-04-03T15:00:00Z
use Calendrics\Duration;
use Calendrics\ZonedDateTime;
$start = ZonedDateTime::parse('2026-03-28T12:00:00+01:00[Europe/Vienna]');
echo $start->add(new Duration(days: 1)); // 2026-03-29T12:00:00+02:00[Europe/Vienna]
echo $start->add(new Duration(hours: 24)); // 2026-03-29T13:00:00+02:00[Europe/Vienna]
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.