Skip to content

joanfabregat/iso8601-to-seconds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ISO 8601 to seconds

Latest Stable Version Total Downloads Latest Unstable Version License

A simple package to convert ISO 8601 duration to seconds

Installation

The package is available on Packagist. The recommended way to install the library is through Composer:

composer require joanfabregat/iso8601-to-seconds

Usage

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

License

The library is published under the MIT license (see LICENSE file).

About

A simple package to convert ISO 8601 duration to seconds

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages