Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

326
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda