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

219
Views
How to convert a date in specific timezone to utc

I am having a date string '2021-09-27 07:43' I also have the info that the date is in (GMT-8:00) Alaska time zone. I am in a different local timezone. When i convert this date to UTC , it is taking my timezone as the reference timezone.

const str = new Date().toLocaleString('en-US', { timeZone: 'Etc/GMT' });

How to do it with respect to a specific time zone as the reference rather than my local time?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can convert it using moment.js. see Example:

var input = '2021-09-27 07:43';
var fmt   = 'YYYY-MM-DD HH:mm';  // must match the input
var zone  = 'Etc/GMT';

var m = moment.tz(input, fmt, zone);

m.utc();

var s = m.format(fmt)  // result:
console.log(s);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.11/moment-timezone-with-data-2010-2020.min.js"></script>

about 4 years ago · Juan Pablo Isaza Report

0

Try:

let myDate = "2021-09-27 07:43";
let myDateUTC = new Date(myDate + " UTC-8"); // 2021-09-27T15:43:00.000Z
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!