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

260
Views
Formatted date as String converted to date wrong

I am trying to store date in DB using the current timezone. I have used library date-fns-tz When I convert the date as a string is okay, but when I want to create that string as a Date it is still a problem.

    const date = new Date();
const date_string = formatInTimeZone(
  date,
  "Europe/Rome",
  "yyyy-MM-dd HH:mm:ss"
);

console.log(date_string); //2022-04-16 11:46:28  (Right time)
const current_date = new Date(date_string); // 2022-04-16T09:46:28.000Z   (Converted to 2h back)
about 4 years ago · Juan Pablo Isaza
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!