0

How can I display a date to behave like that day regardless of the users time-zone?

>>> new Date('2013-09-17')
Date {Mon Sep 16 2013 20:00:00 GMT-0400 (Eastern Standard Time)}

I'm trying to use the jquery datepicker formater, however when I pass the date object it's off by a day. How can I make sure that the users timezone is disregarded?

Moak
  • 12,596
  • 27
  • 111
  • 166
  • Maybe this can help you out : http://stackoverflow.com/questions/2771609/how-to-ignore-users-time-zone-and-force-date-use-specific-time-zone – davidkonrad Sep 17 '13 at 18:03
  • Exact duplicate of [Javascript Date string constructing wrong date](http://stackoverflow.com/questions/18774293/javascript-date-string-constructing-wrong-date) – Matt Johnson-Pint Sep 17 '13 at 19:03

1 Answers1

0

OK, I split the string and passed them as parameters for my expected result.

>>> d = '2013-09-17'.split('-');  new Date(d[0],d[1]-1,d[2]);
Date {Thu Oct 17 2013 00:00:00 GMT-0400 (Eastern Standard Time)}
Moak
  • 12,596
  • 27
  • 111
  • 166