vvo / tzdb

🕰 Simplified, grouped and always up to date list of time zones, with major cities
MIT License
776 stars 54 forks source link

how do i get GMT values from this? #240

Closed deadcoder0904 closed 2 years ago

deadcoder0904 commented 2 years ago

for example, my timezone asia/kolkata has a gmt +5:30. i was wondering how do i get the gmt value as it is useful while displaying?

deadcoder0904 commented 2 years ago

kinda like this select → https://ndom91.github.io/react-timezone-select/

deadcoder0904 commented 2 years ago

also, would love to see how u use it in your application (a screenshot, maybe)?

deadcoder0904 commented 2 years ago

think i've got it.

const timezones = getTimeZones()

const options = timezones.map(({ name, currentTimeFormat }) => {
    const label = `(GMT${currentTimeFormat.substring(0, 6)}) ${name.replace(/_/g, ' ')}`
    return { label, value: name }
})