PHP code example of granam / date-interval
1. Go to this page and download the library: Download granam/date-interval 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/ */
granam / date-interval example snippets
use Granam\DateInterval\DateInterval;
$interval = new DateInterval('P2H');
echo $interval->toSeconds(); // "7200"
echo $interval->toSpec(); // "P2H"
$fromSeconds = DateInterval::fromSeconds(7201);
echo $fromSeconds->toSpec(); // P2HS1