0

I want to show on my website current india time using javascript and i need to access the hour,min,sec,day because i want to make a ticking clock with that

I now if we have a new Date() object we can do this via

     currentTime = new Date();

     var h = currentTime.getHours();
     var m = currentTime.getMinutes();
     var s = currentTime.getSeconds();

But this method shows the local time of the user i want to always show the Indian time doesn't matter where the user is. How I can input the offset in the new date object so that it gives me Indian time

I tried this

   utc = new Date().getTime();

  var current_indian_Time = new Date(utc + (3600000*offset));

But this is not working

There is too many answers on the StackOverflow i am totally confused. Thanks

beginner
  • 2,366
  • 4
  • 29
  • 53
  • do you consider in using a plugin? or just pure javascript? – Shadow Fiend Oct 02 '17 at 08:28
  • @ShadowFiend If it is possible with javascript or jquery, It would be great, But if not possible, i can use plugin. Thanks – beginner Oct 02 '17 at 08:29
  • There's answer here https://stackoverflow.com/questions/8207655/how-to-get-time-of-specific-timezone-using-javascript and https://stackoverflow.com/questions/10087819/convert-date-to-another-timezone-in-javascript – artgb Oct 02 '17 at 08:33
  • You have `new Date().getTimezoneOffset()` on your client which returns the offset in minutes. From there just add the offset of india to the date. – kevinSpaceyIsKeyserSöze Oct 02 '17 at 08:34
  • @kevinSpaceyIsKeyserSöze ,artgb Thanks guys for leading me to the right path. – beginner Oct 02 '17 at 08:36

0 Answers0