ISO-8601 UTC datetimes in web-applications
The best way to handle dates in web-apps (especially a backend side) is using ISO-8601 standart (DB dates, input params, responses).
An example of an ISO-8601 UTC datetime: ‘2019-03-02T13:27:40Z’.
Usage:
- npm install moment –save or npm install moment-timezone –save:
- get a Moment (UTC mode) by a current system time:
- print a current system time (my system time is GMT+5):
- print a current system UTC time (my system time is GMT+5)
- get a Moment (UTC mode) by a UTC date (string)
- get a JS Date by a UTC date (string)
- check is a valid ISO 8601 date (string)
- convert a UTC date (string) to a Moment with changed timeozne
- get a JS Date by a UTC date (string)
- change the timezone to ‘America/Los_Angeles’
- convert a timezone date (string) to a Moment (with a timezone offset)
- get a Moment by a date (string) and a timezone
- get a Moment (UTC mode)