0

If the request has been made from the US it must give the present date and time Of US, if India then it must provide date and time in India. Also my server will be deployed on the US server, will it affect when i try to get the current date.

Ozan
  • 3,709
  • 2
  • 18
  • 23
Shantanu Madane
  • 617
  • 5
  • 14
  • Possible duplicate of [Getting the client's timezone in JavaScript](http://stackoverflow.com/questions/1091372/getting-the-clients-timezone-in-javascript) – James Aug 12 '16 at 06:09

1 Answers1

1

You may want to keep track of the difference between local time and UTC time....

var d = new Date()
var n = d.getTimezoneOffset();

the variable d is the time in UTC, n is the difference (in minutes) between the UTC time and the local time... I usually set my time as the UTC time, but display the local time...

PhoenixBlue
  • 967
  • 2
  • 9
  • 26
  • I know this will provide me an offset between GMT timings i am looking for an exact answer to solve this problem – Shantanu Madane Aug 12 '16 at 07:06
  • I m not sure I understand the question but if you want to display the local time as per the request, then add the UTC time and the offset. or to make it simple (that's my opinion), just display the UTC time and between brackets, add the offset (in hours maybe). so your display becomes something like: 1:54 pm (-6:00) for some state in the US and 1:57 (+4:00) for India maybe... – PhoenixBlue Aug 13 '16 at 16:45