PHP code example of inthere / datetime-range

1. Go to this page and download the library: Download inthere/datetime-range 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/ */

    

inthere / datetime-range example snippets


$parser = new Parser(
    '["2015-08-14 16:07:28.956968+02","2018-08-14 16:07:28.956968+02"]',
     new DateTimeZone('UTC')
);
$dateTimeRange = $parser->parse();

$lowerRange = $dateTimeRange->getLowerRange();
$upperRange = $dateTimeRange->getUpperRange();

$lowerRange->isInfinity(); 
// returns a boolean

$lowerRange->getDateTime(); 
// returns a datetime object or null if infinity

$lowerRange->getBoundary(); 
// returns a boundary object

$boundary = $lowerRange->getBoundary();

$boundary->isLower(); 
// returns a boolean (true = lower, false = upper)

$boundary->isInclusive(); 
// returns a boolean (true = inclusive, false = exclusive)