简体   繁体   中英

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.

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');
            },
        },

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM