Welcome Guest. Sign in or Signup

0 Comments

How to parse a date string disregarding time zones?

Asked by: 1991 views
b) JSON

0
0

Usually when you parse a date string, it’s in ISO format and the converted Date object will be in the browser’s current culture format.

// This localDate will not however be "Jan 1st 2012, 12AM". It will instead be adjusted to a local time
// like "Dec 31st, 2011, 7PM" if you are in US EST time.
var localDate = new Date( "2012-01-01T00:00:00Z" );

However, if you want the Date object’s time to be the same as what is represented in the string, you can do this:

localDate.addMinutes( localDate.getTimezoneOffset() );
// addMinutes is an API from <a href="http://www.datejs.com/">Date.js</a>.

Comments on Question