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

331
Views
How to use day.js module to set a timezone and convert a set time from EST to UTC?

I am reading in a variable string, DateTime = "2019-11-21T08:29:56EST", from another file. The format of this string with the 'EST' is a outlier for my files. I want to identify this time as EST, remove the characters of "EST" from the string or obtain just the time "2019-11-21T08:29:56" and convert the time to UTC. Here is what I have tried so far. I think dayjs is assuming DateTime is in UTC which is preventing th conversion from happening.

  var dayjs = require('dayjs');
  var utc = require('dayjs/plugin/utc');
  var timezone = require('dayjs/plugin/timezone'); // dependent on utc plugin
  dayjs.extend(utc);
  dayjs.extend(timezone);

  var DateTime = "2019-11-21T08:29:56EST"

  var split_DateTime = DateTime.split("EST")

  if (DateTime.includes("EST")) {
    var UTC_DateTime = dayjs.tz(split_DateTime[0]).tz("UTC").format('YYYY-MM-DDTHH:mm:s'); 
  } else{
    var UTC_DateTime = split_DateTime[0];
  }

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!