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

155
Views
Javascript adding Timezone in my current script

i have this code on my script to show ticking clock

<script type="text/javascript">
    function showTime() {
        var date = new Date(),
            time = new Date(Date.UTC(
                date.getFullYear(),
                date.getMonth(),
                date.getDate(),
                date.getHours(),
                date.getMinutes(),
                date.getSeconds()
            ));

        document.getElementById('time').innerHTML = time.toLocaleTimeString();
    }

    setInterval(showTime, 1000);

</script>

Anyone know how to change the timezone to a specific timezone like "Asia/Jakarta" Thanks before!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

for info : list of TZ (Time Zone)

you can change undefined to 'en-US' => get a country-specific presentation
(en-US is AM/PM, fr-FR -> 24h format, undefined -> local browser format)

see also : Javascript HTML Multiple Timezone Clock

const
  timeLocal   = document.querySelector('#time-Local span')
, timeLA      = document.querySelector('#time-US-LA span')
, timeJakarta = document.querySelector('#time-Jakarta span')
;

let currentDate = new Date();

timeLocal.textContent   = currentDate.toLocaleTimeString()
timeLA.textContent      = currentDate.toLocaleTimeString(undefined, {timeZone:'America/Los_Angeles'} )
timeJakarta.textContent = currentDate.toLocaleTimeString(undefined, {timeZone:'Asia/Jakarta'} )
p      { width: 16em; }
p span { float: right;}
<p id="time-Local"> local time: <span></span> </p>
<p id="time-US-LA"> Los_Angeles time: <span></span> </p>
<p id="time-Jakarta"> Jakarta time: <span></span> </p>

about 4 years ago · Juan Pablo Isaza Report

0

try something like this. usaTime = date.toLocaleString("en-US", {timeZone: "America/New_York"});

about 4 years ago · Juan Pablo Isaza Report
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!