1. Go to this page and download the library: Download dpeuscher/util 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/ */
dpeuscher / util example snippets
$from = '5'; // possible also: '1.5.', '5-1', '2018-05-01'
$to = '7';
$dateHelper = new DateHelper();
list($fromDateTime, $toDateTime) = $dateHelper->buildDateTimeRangeFromTwoInputs($from, $to);
// Default $to is generated by third parameter as DateInterval:
// list($fromDateTime, $toDateTime) = $dateHelper->buildDateTimeRangeFromTwoInputs($from, null, 'P2M');
var_export([$fromDateTime->format('Y-m'), $toDateTime->format('Y-m')]);
$dateHelper = new DateHelper();
$date = $dateHelper->buildDateTimeSince('P3D'); // Interval param defaults to P7D = 1 week - will use P1D if not parsable
print($date->format('Y-m-d'));
$dateHelper = new DateHelper();
$text = $dateHelper->diffToText(new DateInterval('P3DPT4H5M6S'));
print($text);