PHP code example of ealore / dateinterval

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

    

ealore / dateinterval example snippets




use Ealore\DateInterval;

$interval = new DateInterval('P5W1D');
// with this implementation it is possible to specify both weeks and days in the same specification string

echo $interval->w; // outputs 5
echo $interval->d; // outputs 1

$legacy = $di->legacy();

echo $legacy->w; // outputs 0
echo $legacy->d; // outputs 36

$interval = new DateInterval('P5W1D');

echo $interval->getIntervalSpec(); // outputs P5W1D


$zero_interval = new DateInterval('P0D');

echo $interval->getIntervalSpec(); // outputs P0D