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

258
Vistas
How would I take a start/end dates user input, and convert it to US Pacific time, in ISO format?

I need to work a date object thru a specific set of circumstances.

  1. user is inputting a daterange, from/to.
  2. each date needs to be converted toISOString() because that's how it is in the DB.
  3. client wants the dateranges to hard convert to US Pacific time.

So when the user chooses from/to dates, the app is makes their chosen dates in US Pacific timezone, and then searches the db using ISO formatted dates.

I have this SE Post which gets me the timezone conversion, but in a non-iso format. Any attempts at deriving toISOString() molests the object right back to the device timezone.

I'm trying dayjs(), but it winds up being a bunch of extra steps, only to have the end result be molested to the device timezone.

How can I get the above series of events to unfold in the necessary order?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Here is how you do it with dayjs

const dayjs = require("dayjs");
const utc = require("dayjs/plugin/utc");
const timezone = require("dayjs/plugin/timezone");

dayjs.extend(utc);
dayjs.extend(timezone);
let t = dayjs()
  .tz("America/Los_Angeles")
  .utc(true)
  .toISOString();

console.log(t);

Here is a list of all timezones https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

I personally live in europe, but when i execute this script it shows me the time in los angeles in ISO format

about 4 years ago · Juan Pablo Isaza Denunciar
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