I am converting all the visitors local times to UTC using momentJs
visitor_utc = moment().utc().valueOf()
and getting the offset like this
visitor_utc_offset = moment().utcOffset().valueOf() / 60
I would like to have a drop-down list filled with offsets (... -01:00, +00:00, +01:00, +02:00 ....) so the user can change and set his actual offset. The default selected value will be the visitor_utc_offset
Is there any method to get a list of offsets using momentJs ?
With moment-timezone it's possible to do something like that :
for element in moment.tz.names()
console.log moment.tz(element).format("Z")
But it gives a long list with a redundant values (because I am just formatting the timezones names which can have the same offset)
I also found a list in Wikipedia List_of_UTC_time_offsets But I am just not sure if it's a complete list, and it's reliable for the future ?
UPDATE
To compare the list of offsets used in moment-timezone and the one from Wikipedia I used this code :
for element in moment.tz.names()
if $.inArray( moment.tz(element).format("Z"), arr ) <= -1
arr.push moment.tz(element).format("Z")
Which eliminate all double entries, so I've got an array like this :
["+00:00", "+03:00", "+01:00", "+02:00", "-09:00", "-08:00", "-04:00", "-03:00", "-05:00", "-06:00", "-04:30", "-07:00", "-02:00", "-02:30", "+08:00", "+07:00", "+10:00", "+11:00", "+05:00", "+12:00", "+06:00", "+05:30", "+09:00", "+04:00", "+04:30", "+05:45", "+06:30", "-01:00", "+09:30", "+08:45", "+10:30", "-10:00", "-11:00", "-12:00", "+13:00", "+14:00", "+12:45", "-09:30", "+11:30"]
This array contains 39 offsets, but In Wikipedia there are 40 offsets
So After looking for a while I was able to found that in Wikipedia you can find the offset +03:30 and -03:30 but in the moment-timezone you can't !!
That's a weird thing !?