2017 © Pedro Peláez
 

library date-time-parser

Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350].

image

yalesov/date-time-parser

Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350].

  • Wednesday, July 6, 2016
  • by yalesov
  • Repository
  • 1 Watchers
  • 3 Stars
  • 115 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 11 Versions
  • 4 % Grown

The README.md

Yalesov\DateTimeParser

Build Status, (*1)

Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350]., (*2)

Installation

Composer:, (*3)

{
  "require": {
    "yalesov/date-time-parser": "2.*"
  }
}

Usage

Parse an ISO-8601 date/time

use Yalesov\DateTimeParser\Parser;

$datetime = Parser::parseDateTime('19961022T140000+0800');
// $datetime['year']     = '1996';
// $datetime['month']    = '10';
// $datetime['day']      = '22';
// $datetime['hour']     = '14';
// $datetime['minute']   = '00';
// $datetime['second']   = '00';
// $datetime['timezone'] = '+0800';

$datetime = Parser::parseDateTime('---22T14');
// $datetime['year']     = null;
// $datetime['month']    = null;
// $datetime['day']      = '22';
// $datetime['hour']     = '14';
// $datetime['minute']   = null;
// $datetime['second']   = null;
// $datetime['timezone'] = null;

Full function signature:, (*4)

public static function parseDateTime($datetime)

It accepts an ISO-8601 date-and-or-time string and returns an array of datetime units. It will throw an InvalidArgumentException if the input is not a valid date/time expression, or if the date/time specified is invalid., (*5)

Missing date/time units will be filled with null., (*6)

Standalone time expressions must be prefixed with T., (*7)

To parse an ISO-8601 date expression, use:, (*8)

public static function parseDate($date)

To parse an ISO-8601 time expression, use:, (*9)

public static function parseTime($time)

The return array for these two functions are same as Parser::parseDateTime()., (*10)

Create an ISO-8601 date/time

use Yalesov\DateTimeParser\Parser;

$expr = Parser::createDateTime('1996', '10', '22', '14', '00', '00', '+0800');
// $expr = '19961022T140000+0800';

$expr = Parser::createDateTime(null, null, '22', '14', null, null, null);
// $expr = '---22T14';

These are simply reverses of the parse-() functions., (*11)

Full function signatures:, (*12)

public static function createDateTime(
  $year = null, $month = null, $day = null,
  $hour = null, $minute = null, $second = null, $timezone = null)
public static function createDate($year = null, $month = null, $day = null)
public static function createTime($hour = null, $minute = null, $second = null, $timezone = null)

Valid ranges:, (*13)

  • Year: (unlimited)
  • Month: 01-12
  • Day: 01-31
  • Hour: 00-23
  • Minute: 00-59
  • Second: 00-59

Note that 0-prefixed numbers are different from 0-prefixed strings. For example, if you mean August, write 8 or '08', not 08., (*14)

Create a timestamp from a complete or partial date/time

public static function createTimestamp(
  $year = null, $month = null, $day = null,
  $hour = null, $minute = null, $second = null, $timezone = null)

Accepted arguments are same as the create-() series., (*15)

Parser::createTimestamp() will create a timestamp if at least year, month, day are given (and valid). It will assume '00' for hour, minute and second if not given; and script timezone if timezone is not given., (*16)

Return null if failed to create a timestamp., (*17)

The Versions

06/07 2016

dev-master

9999999-dev https://github.com/yalesov/php-date-time-parser

Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350].

  Sources   Download

ISC

The Requires

 

The Development Requires

by Yulij Andreevich Lesov

datetime iso8601 vcard iso-8601

06/07 2016

v2.1.1

2.1.1.0 https://github.com/yalesov/php-date-time-parser

Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350].

  Sources   Download

ISC

The Requires

 

The Development Requires

by Yulij Andreevich Lesov

datetime iso8601 vcard iso-8601

05/07 2016

v2.1.0

2.1.0.0 https://github.com/yalesov/php-date-time-parser

Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350].

  Sources   Download

ISC

The Requires

 

The Development Requires

by Yulij Andreevich Lesov

datetime iso8601 vcard iso-8601

05/07 2016

v2.0.3

2.0.3.0 https://github.com/yalesov/php-date-time-parser

Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350].

  Sources   Download

ISC

The Requires

 

The Development Requires

by Yulij Andreevich Lesov

datetime iso8601 vcard iso-8601

05/07 2016

v2.0.2

2.0.2.0 https://github.com/yalesov/php-date-time-parser

Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350].

  Sources   Download

ISC

The Requires

 

by Yulij Andreevich Lesov

datetime iso8601 vcard iso-8601

05/07 2016

v2.0.1

2.0.1.0 https://github.com/yalesov/php-date-time-parser

Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350].

  Sources   Download

ISC

The Requires

 

by Yulij Andreevich Lesov

datetime iso8601 vcard iso-8601

05/07 2016

v2.0.0

2.0.0.0 https://github.com/yalesov/php-date-time-parser

Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350].

  Sources   Download

ISC

The Requires

 

by Yulij Andreevich Lesov

datetime iso8601 vcard iso-8601

03/10 2012

1.0.3

1.0.3.0 https://github.com/heartsentwined/date-time-parser

Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350].

  Sources   Download

GPL-3.0

The Requires

 

by Avatar heartsentwined

datetime iso8601 vcard iso-8601

28/09 2012

1.0.2

1.0.2.0 https://github.com/heartsentwined/date-time-parser

Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350].

  Sources   Download

GPL-3.0

The Requires

 

by Avatar heartsentwined

datetime iso8601 vcard iso-8601

06/09 2012

1.0.1

1.0.1.0 https://github.com/heartsentwined/date-time-parser

Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350].

  Sources   Download

GPL-3.0

The Requires

 

by Avatar heartsentwined

datetime iso8601 vcard iso-8601

06/09 2012

1.0.0

1.0.0.0 https://github.com/heartsentwined/date-time-parser

Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350].

  Sources   Download

GPL-3.0

The Requires

  • php >=5.3.3

 

by Avatar heartsentwined

datetime iso8601 vcard iso-8601