最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - Get Indian standard time not system time in javascript - Stack Overflow

programmeradmin1浏览0评论

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
Add a ment  | 

2 Answers 2

Reset to default 4

Javascript 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

发布评论

评论列表(0)

  1. 暂无评论