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

325
Visualizações
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
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