fabiang / dateparser
Parser for date strings
v2.1.0
2024-01-24 13:11 UTC
Requires
- php: ^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0
- phplrt/runtime: ^3.2
Requires (Dev)
- laminas/laminas-coding-standard: ^2.3
- phplrt/compiler: ^3.2
- phpunit/phpunit: ^9.5.16 || ^10.0
- squizlabs/php_codesniffer: ^3.7
- vimeo/psalm: ^4.23
README
Date parsing library supporting the full format RFC3339. The following formats are supported:
2017-07-25T18:37:40
2017-07-25T18:37:40.1234567890
2017-07-25T18:37:40.1234567890Z
2017-07-25T18:37:40Z
2017-07-25T18:37:40.1234567890+0200
2017-07-25T18:37:40+0200
2017-07-25T18:37:40.1234567890-0400
2017-07-25T18:37:40-0400
2017-07-25T18:37:40.1234567890+02:00
2017-07-25T18:37:40+02:00
2017-07-25T18:37:40.1234567890-04:00
Note: PHP only supports 6 digit microseconds. This library cut the last digits off.
Installation
Run Composer with:
composer require fabiang/dateparser
Usage
Parsing an RFC3339 datetime string:
use Fabiang\Dateparser\RFC3339; $parser = new RFC3339(); $datetime = $parser->parse('2017-07-25T18:37:40+02:00'); // DateTime object
Licence
BSD-2-Clause. See the LICENSE.md.