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

181
Views
Change date format of moment(obj.created_at).toDate()

I need to change format from 2022-12-30 to 30-12-2022 (DD/MM/YYYY)

But I need to keep it as DATE object, not as string

Here what I've tried:

obj.created_at                                        // return string 2022-12-30 (YYYY-MM-DD)
new Date(obj.created_at)                              // return date 12/30/2022 (MM/DD/YYYY)
new Date(obj.created_at).toLocaleDateString('id-ID')  // return string 30/12/2022 (DD/MM/YYYY), this is the correct format, but it's a string not a date
moment(obj.created_at).toDate()                       // return date 12/30/2022 (MM/DD/YYYY)
moment(obj.created_at).format('DD/MM/YYYY')           // return string 30/12/2022 (DD/MM/YYYY), this is the correct format, but it's a string not a date
moment(obj.created_at, 'YYYY-MM-DD').toDate()         // return date 12/30/2022 (MM/DD/YYYY)

Thank you :)

about 4 years ago · Juan Pablo Isaza
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!