Parse .Net JSON dates to DateTime object, and convert DateTime object to .Net JSON date format.
You can install the package via composer:
composer require webapix/dot-net-json-date-formatter
To parse .NET JSON dates:
use \Webapix\DotNetJsonDate\Date;
Date::toDateTime('/Date(1593432000000+0200)/'); // return with \DateTime object
If the Json string is invalid, it will throw an \Webapix\DotNetJsonDate\InvalidJsonDateString exception.
To convert DateTime to JSON date:
use \Webapix\DotNetJsonDate\Date;
$dateTime = DateTime::createFromFormat('Y-m-d H:i:s', '2020-06-29 12:00:00');
Date::toJsonDate($dateTime); // return with: /Date(1593432000000+0000)/
composer test
According to the postcardware concept, if you use the software for your project(s) we would appreciate to receive a postcard of your hometown.
Please send it to:
WEBAPIX KFT.
Kőris utca 2/E, 2/1
2051 Biatorbágy
Hungary
If you find our packages useful and would like to support our work in maintaining and regularly updating them, consider becoming a patron. Any size of donation is welcome and highly appreciated.
Contributions are welcome! When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
Please see CHANGELOG for more information on what has changed recently.
If you discover any security related issues, please email pdo@webapix.hu instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.