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

258
Vistas
How to convert utc to utc+1 in javascript

I got this value from a server 06:21:00 but the real time in 07:21:00 which is one hour later. I think the value is in UTC and I have to change it to UTC+1. so that my code can get the time and change it to UTC+1 and one hour will be added automatically.

Process: I will get the value from Server then pass it to my javascript code and the js code will change it to UTC+1 (which one hour will be added) and show the value.

How can I convert the gotten value to UTC+1 (TimeZone Berlin)

Second Question: I wrote the new Date().toUTCString() and the result it shown in english, can I show the result in germany ? like the week days? Thanks

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I'm not a JS-Pro so I don't think my code is beautiful but it works !

h = "06:21:00".split(":")
n = (parseInt(h[0]) + 1) % 24
if (n.length = 1){
  n= "0" + n;
}
result = n + ":" + h[1] + ":" + h[2]
console.log(result)
about 4 years ago · Juan Pablo Isaza Denunciar

0

I believe this is what you are looking for?

It will take the timestamp from the server in UTC and convert it appropriately to a date object where you can get the time back in your local timezone.

From there, you can map the numerical representation of the day and the month index to their German day and month abbreviations and put manually build a time string.

let time = '06:21:00';
let date = new Date();
date.setUTCHours(...time.split(':'));

let days = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'];
let months = ['Jan', 'Feb', 'März', 'Apr', 'Mai', 'Juni', 'Juli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dez'];

let str = `${days[date.getDay()-1]} ${months[date.getMonth()]} ${date.getDate()} ${date.getFullYear()} ${date.toTimeString()}`;

console.log(str);

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