0

In my scenario, user enters the date and the timezone of that date.

The user may be in any timezone Say, the given date is 2nd Feb 2015 06:00:00 for EST (GMT-0500). The user is in IST (GMT+0530).

If i create a give,

var ScheduleOn = new Date('02/02/2015 06:00:00')

ScheduleOn is Mon Feb 02 2015 06:00:00 GMT+0530 (IST)

It is creating date in IST format.

I have tried specifying time zone also ( var ScheduleOn = new Date('02/02/2015 06:00:00 UTC-0500') ), it is not working.

I need time in the local time zone (IST) for the given time in the given timezone (EST).

What I need is ScheduleOn is Mon Feb 02 2015 16:30:00 GMT-0500 (EST)

Prabakaran Raja
  • 720
  • 1
  • 11
  • 27
  • possible duplicate of [How to initialize javascript date to a particular timezone](http://stackoverflow.com/questions/15141762/how-to-initialize-javascript-date-to-a-particular-timezone) – spokeadoke Jan 27 '15 at 17:53
  • Something like this? var ScheduleOn = new Date('02/02/2015 06:00:00'); var timeZoneDifference = -5; var ScheduleOnCorrected = new Date(ScheduleOn.getTime() + timeZoneDifference * 60 * 60 * 1000); // 60 min * 60 sec * 1000 milisec = 1 hour – webtrick101 Jan 28 '15 at 07:28
  • 1
    Yes. But that timezone diff must be dynamic. I cant hardcode that – Prabakaran Raja Jan 29 '15 at 11:07
  • var x = new Date(); var timeZoneDifference = x.getTimezoneOffset()/-60; as in my earlier blog: http://webtrick101.blogspot.com/2013/08/my-javascript-function-to-show-utc-time.html – webtrick101 Feb 05 '15 at 02:04

0 Answers0