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

160
Vistas
Format output date using date-fns with ReactJs

Can you guys help with a custom format output using date-fns react library?

I'm trying to format this date '2022-01-24T05:26:28+0000' to '24 jan 2022, às 02:26', but the 's' is for second, so the output is something like this '24 jan 2022, à28 02:26' Is there a way to prevent the 's' to format?

My code:

{format(
    new Date(post.data.last_publication_date),
    `PP, às p`,
    { locale: ptBR }
)}

I already tried using template literals such as ${`PP, às p`}, but it didn't help.

I'm using ReactJs and NextJs with this library.

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

0

So, I read more deep the docs from the library and they have some patterns to edit the output.

To the date '2022-01-24T05:26:28+0000' be format as '24 jan 2022, às 02:26', it requires some simple quotes, as follows:

`PP, 'às' p`

So the output will be '24 jan 2022, às 02:26'

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