PHP code example of gugiman / date-period-parser8601
1. Go to this page and download the library: Download gugiman/date-period-parser8601 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/ */
gugiman / date-period-parser8601 example snippets
use Gugiman\DatePeriodParser8601;
//$string = "2022-05-10";
//$string = "2022-05";
//$string = "201X";
$string = "2022-W25-WE";
$obj = new DatePeriodParser8601($string);
$obj->getStart();
// returns \DateTime object of start
// $obj->getStart()->format("d.m.Y H:i:s");
// returns 22.06.2022 00:00:00
$obj->getEnd();
// returns \DateTime object of end
// $obj->getEnd()->format("d.m.Y H:i:s");
// returns 23.06.2022 23:59:59
// returns \DatePeriod object with given interval
$obj->asDatePeriod(new \DateInterval("P1D"));