0

I am converting a string to datetime as below and showing it in textbox with labelFormat "dd/MM/yyyy"

 var datetime=new Date("1996-07-04T00:00:00");

But the value of datetime is different in different browser when the time zone is US

In firefox- 4/7/1996 in Chrome- 3/7/1996

So i passed string value with Z as below. Now the values are same but instead of day 4, its showing 3.

var datetime=new Date("1996-07-04T00:00:00Z");

Showing 3/7/1996 instead of 4/7/1996.

Is there anyother options or am i doing anything wrong

Thaanks in advance

user3326265
  • 257
  • 1
  • 4
  • 14
  • I'm not entirely sure how timezones work in javascript, but shouldn't the 4th at midnight UTC be some time on the 3rd anywhere in the US? ie, this is to be expected, and the original behaviour (without the `Z`) is down to different browsers parsing it differently (one as local, one as UTC) – James Thorpe Mar 23 '15 at 12:23
  • Related Question: http://stackoverflow.com/questions/10269513/date-constructor-numeric-arguments-vs-string-argument-giving-different-dates-i – Diptendu Mar 23 '15 at 12:26
  • Try using http://momentjs.com/ , does the issue still occur? – Wesley Smith Mar 23 '15 at 12:37

0 Answers0