Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

154
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

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

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda