PHP code example of joanfabregat / iso8601-to-seconds
1. Go to this page and download the library: Download joanfabregat/iso8601-to-seconds 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/ */
joanfabregat / iso8601-to-seconds example snippets
use JoanFabregat\Iso8601ToSeconds\Iso8601ToSeconds;
$seconds = Iso8601ToSeconds::convert('PT1H');
echo $token; // will echo 3600
$interval = new DateInterval('PT1H');
$seconds = Iso8601ToSeconds::convert($interval);
echo $token; // will echo 3600
$interval = DateInterval::createFromDateString('1 hour');
$seconds = Iso8601ToSeconds::convert($interval);
echo $token; // will echo 3600
// will throw an \InvalidArgumentException exception
$token = Iso8601ToSeconds::convert('a random string');