Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!