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

807
Views
Format Date in MUI DataGrid

How can i format the date data in MUI DataGrid from mongo format to moment.

Also I want to include an extra field with the edit icon which when clicked, would redirect to the edit page

Here's what i have.

 const columns = [

    { field: 'createdAt', headerName: 'Join Date', width: 100 },
    { field: *****, headerName: 'Edit', width: 120 }
]

I get my output as 2022-04-03T09:24:40.199Z. I want to format it using moment.js. how can i achieve this?

Is there a way of including the edit icon and passing the id of the clicked item

Since the field contains the data from the database represented by a string. I have tried template literals. It didn't work as well.

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

0

Try adding valueFormatter property into createdAt field object as shown in the code below.

...

{ 
  field: 'createdAt', 
  headerName: 'Join Date', 
  width: 100,
  valueFormatter: params => 
    moment(params?.value).format("DD/MM/YYYY hh:mm A"),
},

...

You can also find more about DataGrid cell customization in this document:

https://mui.com/x/react-data-grid/column-definition/#rendering-cells

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!