-2

is it possible to get the current time by providing timezone in javascript? Here I have- timezone - America/Detroit

var d = new Date();

is it possible to get current time by providing America/Detroit ?

Amara
  • 341
  • 4
  • 19
  • I presume you're asking because you are not in that timezone. – phuzi Jan 10 '22 at 10:03
  • 1
    Welcome to Stack Overflow! Visit the [help], take the [tour] to see what and [ask]. Please first ***>>>[Search for related topics on SO](https://www.google.com/search?q=javascript+get+time+from+timezone+site:stackoverflow.com)<<<*** and if you get stuck, post a [mcve] of your attempt, noting input and expected output using the [`[<>]`](https://meta.stackoverflow.com/questions/358992/ive-been-told-to-create-a-runnable-example-with-stack-snippets-how-do-i-do) snippet editor. – mplungjan Jan 10 '22 at 10:03
  • [Here](https://stackoverflow.com/questions/70608037/how-can-use-romance-standard-time-to-set-the-time-zone/70608565#70608565) is an example how to do it. – MrJami Jan 10 '22 at 10:04
  • https://stackoverflow.com/questions/8207655/get-time-of-specific-timezone – mplungjan Jan 10 '22 at 10:05

1 Answers1

0
let date = new Date;

let strTime = date.toLocaleString("en-US", { timeZone: 'America/Detroit' }); console.log(timeZone, strTime);

Vishal Kardam
  • 24
  • 1
  • 9