How To Display JavaScript Date In Specific Time Zone
JavaScript
19/01/2023
Given a value of type Date
, you can get a date string representation of a certain time zone as follows.
JAVASCRIPT
const dt = new Date()// Date Thu Jan 05 2023 21:12:29 GMT+0100 (Mitteleuropäische Normalzeit)
dt.toLocaleString("en-GB", { timeZone: "America/New_York" })// "05/01/2023, 15:12:29"
Don't know the string value of a specific timezone? 🤷♀️ Intl.supportedValuesOf('timeZone')
will return an array of all possible values.
- How To Restart Numbering Of Ordered List In DOCX JS
- 'Types Of Property Are Incompatible' In GraphQL CodeGen