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

143
Vistas
date-fns: how to to get the current date + time in format YYYY-MM-DDThh:mm:ss:dddddd

My company is using date-fns and I'm trying to set a variable equal to the current date + time. We must use date-fns, and the format is specified to be 'YYYY-MM-DDThh:mm:ss.dddddd'.

How can I do this? I tried simply format(new Date(), 'YYYY-MM-DDThh:mm:ss:dddddd'), but that was not working as expected.

(Also what is the 'T' for? Just to specify that a time measurement will follow? And what are the d's?)

Thanks!!

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

0

Your pattern is not correct e.g. you need

  1. y instead of Y
  2. d instead of D
  3. H instead of h

etc. Check this page to learn more about these letters.

Demo:

const fns = require('date-fns')

console.log(fns.format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSS"))

Output from a sample run:

2021-08-03T19:43:08.891

ONLINE DEMO

(Note: Click Console on the bottom right of the ONLINE DEMO page.)

(Also what is the 'T' for? Just to specify that a time measurement will follow?

Correct. It is a separator for date and time as per ISO-8601 standards.

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