Written below is the function I wrote in order to get IST. Needless to say, the IST displayed will be just as accurate as accuracy of host computer.
/***Get Indian Standard Time from visitor’s local computer time.
Add getTimezoneOffset to get GMT/UTC
Add +330 minutes (IST is +5.5 hrs ahead of GMT) to get IST
var dte = new Date();
The function written below, converts GMT time string into visitor’s local time, takes care of Daylight Savings too.
/***Get visitor’s Local Time from from GMT time string
sTime : Input date/time/timestamp format string
Any string parsable by Date.parse()
static method is accepted as input.
var dte = new Date(sTime);
Returns the numeric value corresponding to the time for the specified date according to local time from the visitor’s computer. The value returned by the getTime method is the number of milliseconds since 1 January 1970 00:00:00.
Returns the time-zone offset in minutes for the current locale, including Daylight savings time, from visitor’s computer. The time-zone offset is the difference between local time and Greenwich Mean Time(GMT).
Converts a date to a string, using the current locale’s conventions. Different platforms might assemble the input string in different ways depending on the user agent (browser) and operating system settings.