globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 605 forks source link

How to Globalize.parseDate() and interpret date as being in UTC #861

Closed olignyf closed 5 years ago

olignyf commented 5 years ago

I'm using the Bootstrap datetimepicker and it returns me plain date like "3/1/2019, 4:26 PM". Now this can be in any timezone that the user also selected on the page, for example "UTC". But the browser localtime is not relevant at this point. Globalize.parseDate("3/1/2019, 4:26 PM", "M/d/yyyy, h:mm tt", app.locale); returns "Fri Mar 01 2019 16:26:00 GMT-0500" However I don't want it in GMT -5 but in a specific timezone, for example UTC, or GMT +2. Thanks !!

rxaviers commented 5 years ago

Please, post questions in stack overflow according to https://github.com/globalizejs/globalize#contributing, it's a better tool for Q/A. Thanks