Consolidate and standardize date time usage / format across the application
Created by: deepakduggirala
- All time / date stored in the databases (Postgres or MongoDB) should be in UTC time zone
- Any time / date data returned in JSON from APIs should be in ISO 8601 format and in UTC time zone.
- Use browser's local time zone to display dates / times whenever possible. For this use the datetime service.
Usage:
import * as datetime from '@/services/datetime.js'
datetime.date("2023-06-14T01:18:40.501Z") // "Jun 14 2023"
datetime.absolute("2023-06-14T01:18:40.501Z") // "2023-06-13 21:18:40 -04:00"
datetime.fromNow("2023-06-14T01:18:40.501Z") // "2 months ago"
datetime.readableDuration(130*1000) // "2 minutes"
datetime.formatDuration(12000 * 1000) // "3h 20m"