Home  >  Q&A  >  body text

javascript - The Date variable returned in the background is null, but the value taken out using moment.js is Invalid date

As the title states, the time I retrieved in the background is null, but the time displayed using moment.js is Invalid date

The front-end code for using datatable is:

{
    data: 'v.testTime',
    orderable: false,
    render: function (data, type, full) {
    return moment(full.testTime).format("YYYY-MM-DD HH:MM:SS");
    }
},

When testTime is null, the front end displays Invalid date. What is the problem? How can it be displayed as empty? Thank you.

Note: Use google chrome 59.0.3071.115 browser

三叔三叔2662 days ago946

reply all(1)I'll reply

  • 迷茫

    迷茫2017-07-05 10:44:27

    I tried using isValid and found that the entered dates were all invalid, but it works if I don’t use moment.js. The code is changed to this

    {
        data: 'v.testTime',
        orderable: false,
        render: function (data, type, full) {
        return full.testTime;
        }
    },

    I’m depressed. I don’t know why this is happening. There is no problem with the date returned in the background. . .

    reply
    0
  • Cancelreply