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

241
Vistas
javascript date.toString("yyyy-MM-ddTHH:mm:ss.fffZ") or "yyyy-MM-dd HH:mm:ss ZZ" with timezone offset

new Date().toISIOString() or toJSON() provide an unambiguous Date and Time and TimeZone Offset:

"2021-10-07T13:52:14.333Z"

I want the same formatting, or very similar, but without the restriction to UTC :

"2021-10-07T14:52:14.333+0100"

Is there a built-in solution that doesn't involve 20 lines of code and battery of unit tests for edge cases?

The timezone offset seems the tricky thing. Things I've looked at don't seem to offer a 'show the timezone offset' option, only timezone names.

  • toLocaleString()
  • Intl.DateTimeFormat()
  • Intl.DateTimeFormat().formatToParts()

for example, Intl.DateTimeFormat().resolvedOptions() knows:

calendar: "gregory"
day: "2-digit"
locale: "en-GB"
month: "2-digit"
numberingSystem: "latn"
timeZone: "Europe/London"
year: "numeric"

but to know what time "1st April 2020 12:00 Europe/London" was, requires a world history lookup table of when daylight saving starts and ends.

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