Download the PHP package heartsentwined/date-time-parser without Composer
On this page you can find all versions of the php package heartsentwined/date-time-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download heartsentwined/date-time-parser
More information about heartsentwined/date-time-parser
Files in heartsentwined/date-time-parser
Package date-time-parser
Short Description Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350].
License ISC
Homepage https://github.com/yalesov/php-date-time-parser
Informations about the package date-time-parser
Yalesov\DateTimeParser
Parse date and time according to the subset of ISO 8601 date/time format used in Vcard [ISO 6350].
Installation
Usage
Parse an ISO-8601 date/time
Full function signature:
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.
Missing date/time units will be filled with null
.
Standalone time expressions must be prefixed with T
.
To parse an ISO-8601 date expression, use:
To parse an ISO-8601 time expression, use:
The return array for these two functions are same as Parser::parseDateTime()
.
Create an ISO-8601 date/time
These are simply reverses of the parse-()
functions.
Full function signatures:
Valid ranges:
- 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
.
Create a timestamp from a complete or partial date/time
Accepted arguments are same as the create-()
series.
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.
Return null
if failed to create a timestamp.