2017 © Pedro Peláez
 

library dti

Parse ISO 8601 date, duration and interval strings into DateTime objects

image

danharper/dti

Parse ISO 8601 date, duration and interval strings into DateTime objects

  • Thursday, November 12, 2015
  • by danharper
  • Repository
  • 1 Watchers
  • 1 Stars
  • 43,998 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

DTI

Parse ISO 8601 dates and intervals., (*1)

Build Status Total Downloads, (*2)

Installation

Install via Composer by adding the following line to the dependencies in your composer.json:, (*3)

danharper/dti: "~1.0"

And run composer install/composer update, (*4)

Usage

$dti = new danharper\DTI;

Passing a single ISO 8601 datetime string will provide you with an array containing that time, and the current time., (*5)

list($from, $to) = $dti->parse('2007-03-01T13:00:00Z');

Passing a single ISO 8601 duration string will substract that duration from the current time., (*6)

list($from, $to) = $dti->parse('PT2H30M');
// from is set to 2h30m before the current time

Optionally, provide parse() with the default time to use instead of the current time:, (*7)

$dti->parse('PT2H30M', new DateTime('2001-01-01'));

Passing a ISO 8601 duration string consisting of two datetimes, will give you them:, (*8)

$dti->parse('2007-03-01T13:00:00Z/2008-05-11T15:30:00Z');

A duration string consisting of a datetime and a duration will give the datetime provided, and the datetime with the duration added to it., (*9)

$dti->parse('2007-03-01T13:00:00Z/P1Y2M10DT2H30M');

And in reverse, will give you the datetime with the duration substracted, and the datetime:, (*10)

$dti->parse('PT2H30M/2007-03-01T13:00:00Z');

The Versions

12/11 2015

dev-master

9999999-dev https://github.com/danharper/DTI

Parse ISO 8601 date, duration and interval strings into DateTime objects

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

12/11 2015

v1.0.0

1.0.0.0 https://github.com/danharper/DTI

Parse ISO 8601 date, duration and interval strings into DateTime objects

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires