1.0.2 • Published 2 years ago

json-date-fix v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

json-date-fix npm version

JSON serialization/deserialization fix for Date objects

import 'json-date-fix' // need once at the root of your app

// serialization fix: preserve timezone information
console.log(JSON.stringify({ date: new Date(2023, 5, 7) }));

// deserialization fix: change date-string to date-object
console.log(JSON.parse('{"date":"2023-06-07T00:00:00.000+03:00"}'));


//// Console output:
// {"date":"2023-06-07T00:00:00.000+03:00"}
// {date: Wed Jun 07 2023 00:00:00 GMT+0300 (Moscow Standard Time)}