javascript - Timezone Conversion moment js -


i have requirement convert (utc/gmt) time local time based on timezone string provided user using moment js.
eg:

utctime = "2014-06-09t05:36:06.005z" timezone = "5.5" (indian standard time) expected result = "2014-06-09 11:06" 

i have tried code achieve this

var local_date = moment.utc("2014-06-09t05:36:06.005z").zone("+05:30").format('yyyy-mm-dd hh:mm'); console.log('local date', local_date); // 2014-06-09 11:06  

here getting correct result. have put time zone in +05:30 format when put "5.5"(timzone format getting user side) not working @ all.

am getting user time zone following way

-12, -11, .... -1 gmt 1, 2 .. 3.3, 5, 5.5, 5.75 ...  

is there way convert gmt time local using above timezone format. please guide me in right direction. if not possible how can covert user input time zone desired format. thank you

this may http://jsfiddle.net/8qtfy/

var yourvalue=parsefloat("5.5");          moment.utc("2014-06-09t05:36:06.005z").add('hours',yourvalue).format('yyyy-mm-dd hh:mm'); 

Comments

Popular posts from this blog

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -