Skip to content

PHP Class for rudimental parsing of ISO8601 DatePeriods user e.g. by Amazon Alexas Slot type "AMAZON.DATE"

License

Notifications You must be signed in to change notification settings

Gugiman/DatePeriodParser8601

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DatePeriodParser8601

PHP Class for rudimental parsing of ISO8601 DatePeriods e.g. by Amazon Alexas Slot type AMAZON.DATE

Install via composer

Require the package with composer:

composer require gugiman/date-period-parser8601

Using

Use like seen in test.php

<?php

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"));

Donation

BTC: 1Gn4ofNXpvwYSvyi2wC1kT3Hoas3kaifqx

ETH (ERC20): 0x07d2b052abb86df996276fcc327296f344781ae8

About

PHP Class for rudimental parsing of ISO8601 DatePeriods user e.g. by Amazon Alexas Slot type "AMAZON.DATE"

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages