javascript - Does DST need to be manually parsed in UTC conversions with moment.js? -


i'm defining time moment-timezone 2015-06-05 10:00 in greece (utc+2 dst = utc+3). store in utc later use.

from see, when use .local local date it's converted utc+2 ignoring in dst (daylight saving time) , should utc+3.

you can see here:

var moment = require('moment-timezone'),     mytime = moment.tz('2015-06-05 10:00', 'europe/athens')  mytime.format() // '2015-06-05t10:00:00+03:00' // ok, utc+3  mytime.utc().format() // '2015-06-05t07:00:00+00:00' // ok, time changed 7:00  mytime.local().format() // '2015-06-05t09:00:00+02:00' // ??? why doesn't take on account dst?  mytime.utc().local().format() // '2015-06-05t09:00:00+02:00' // should give initial value? not. 

from documentation not clear me if dst considered. missing something? approach on this?

some explanation:

mytime = moment.tz('2015-06-05 10:00', 'europe/athens') 

this creates moment object timezone information attached it.

mytime.format() 

this format using timezone.

mytime.utc().format() 

this converts mytime utc removing timezone information. this destructive operation, changes mytime object. timezone information lost. it's similar this:

mytime.utc(); mytime.format(); 

continuing:

mytime.local().format() 

this disables "is utc" flag of mytime, means when formatted format according own local timezone (again, changes mytime).

mytime.tz('europe/athens').format() 

this return correct timestamp timezone you're interested in, adding timezone information mytime object.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -