Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
JS Timezone not changing

I am trying to run the following code however I cannot get the correct output. This script is supposed to be able to change the date and timezone based up the parameters set, however when outputted the time will show correctly for the timezone but the timezone name will always display my local timezone despite it being referenced to use the timezone that has been set in the first time. The timezone is set for EST As you see with the code the timezone is set to EST however the "t" which displays the text version of the timezone is displaying the local timezone and now using the one specified on line one.

function init() {
  est = new Date().toLocaleString("en-us", { timeZone: "America/New_York" }); // sets timezone to EST
  d = new Date(est); // Declares a new date object
  h = d.getHours();
  m = d.getMinutes();
  s = d.getSeconds();
  t = d.toLocaleString('en-us', { timeZoneName: 'short' }).split(' ').pop();
  clock();
  day = d.getDate();
  month = d.getMonth();
  year = d.getFullYear();
};
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!