GeekCoder
GeekCoder

Reputation: 140

How to format Jquery Jtable date field edit problem?

I have a jtable jquery where I get the date from javahibernate pojo change to json and it gets auto change to this format Apr 7, 2020 12:00:00 AM. In my jtable the display format for the field is set to 'dd-MMM-yyyy' I get the following error:

jTable WARNING: Given date is not properly formatted: Apr 7, 2020 12:00:00 AM

This only happens when the field type is date

 start_date: {
                 title: 'Date',
                 type: 'date',
                 displayFormat:'dd-MMM-yyyy',
                 list: true,
                 width: '8%'
                }

Can anyone help me to get the formatting fixed? I tried the same in pojo but it's not working.

Upvotes: 1

Views: 305

Answers (1)

hardika
hardika

Reputation: 642

Use moment jquery library. This is what I have done to change the date format.

       date: {
            title: 'Date',
            display: function(data) {
                return moment(data.record.timestamp).format('YYYY-MM-DD');
            },
        },

Upvotes: 0

Related Questions