Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

252
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda