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

255
Views
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 answers
Answer question

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 Report

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 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!