React Data Table Component and Moment

I am using React Data Table Component for displaying table data – which works great!

I have a row field for lastLogin time, which is stored in MongoDB as a model like so:

lastLogin: [{
 type: Date,
 required: false,

My data table component looks like so:

      sortIcon={<ChevronDown />}

Using columns when I try and render the date with moment, it works fine:

    name: 'Last Login',
    selector: (row) => row.lastLogin,

will result in:

However, when formatting with moment, it seems to be obtaining the previous records results.

    name: 'Last Login',
    selector: (row) => row.lastLogin,
    format: (row) => moment(row.lastLogin).format('lll'),

will result in:

Source: React – Stack Overflow

November 17, 2021
Category : News
Tags: momentjs | react-data-table-component | reactjs

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.