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

123
Views
Format date according user locale with date-fns

I'm using date-fns and I would like to display dates as per user’s selected locale (language+region) for example: “Jan 12, 2021” for en_US or “12 Jan 2021.” for en_CA., There is a way to achieve this with date-fns?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The P patterns to format deal with localization: https://date-fns.org/v2.25.0/docs/format

Looks like you would want the PP variant and can be used like this:

import { caLocale } from 'date-fns/locale/ca'

const result = format(new Date(2021, 0, 12), "PP", {
  locale: caLocale
})
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!