Hi I am trying to get current indian date and time. when I use function new Date() function
I get local system time is there any way to get real indian standard time not local time here is my code
var currentDa = new Date();
var nowTime = new Date(currentDa.getTime());
var Chour = nowTime.getHours();
var Cminute = nowTime.getMinutes();
var currentTime = (+Chour + "." + Cminute);
Hi I am trying to get current indian date and time. when I use function new Date() function
I get local system time is there any way to get real indian standard time not local time here is my code
var currentDa = new Date();
var nowTime = new Date(currentDa.getTime());
var Chour = nowTime.getHours();
var Cminute = nowTime.getMinutes();
var currentTime = (+Chour + "." + Cminute);
Share
Improve this question
asked Sep 20, 2015 at 14:02
Himanshu GuptaHimanshu Gupta
691 silver badge10 bronze badges
2 Answers
Reset to default 4Javascript code is
d = new Date();
utc = d.getTime() + (d.getTimezoneOffset() * 60000);
nd = new Date(utc + (3600000*+5.5));
var ist = nd.toLocaleString();
console.log("IST now is : " +ist);
You are correct the Date function of javascript return your system time. Actually there was link which used to work before JSON time service "json-time.appspot." is broken. Anyone have a replacement?
the link is broken but if you can setup the environment the guy mention in github it is good (personally i never tried )
the best what i have done in this case is use accuweather time API: https://apidev.accuweather./developers/timeZones
going to use for personal that fine for mercial check this link:
Is the AccuWeather API free for mercial use?
I believe this solve your problem