1

Hello I know this is a very normal question but I did not find the solution since 3 hours . My firebase time is set to us central . I want the current Indian time

this is my code

var formatedTime = new Date().getHours() + ':' + new Date().getMinutes();

It is giving me server time . How to convert it to Indian region current Time

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
rahul
  • 408
  • 6
  • 21
  • See https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone for a good explanation of JavaScript dates and timezones. – Frank van Puffelen Oct 12 '20 at 14:33

1 Answers1

1

You should maintain the new Date() as it is in UTC. Instead, use toLocaleString for India specific time:

new Date().toLocaleTimeString("en-US", {timeZone: "Asia/Kolkata"})

or

new Date().toLocaleString("en-US", {timeZone: "Asia/Kolkata"})
Réti Opening
  • 1
  • 1
  • 6
  • 21