how to make condition in ajax with date if null not display default format 1970/01/01?

  ajax, javascript

i just want to if the data date null from my database not showing the default.

.done(function(dt) {
            if (dt != null) {
                console.log(dt)
                table.rows().remove().draw();
                $.each(dt, function(i, item) {
                    var d = new Date(item.date);
                    var day = d.getDate();
                    var month = d.getMonth() + 1;
                    var year = d.getFullYear();

                    var d_date= day + "/" + month + "/" + year;
                    
                    table.row.add([
                        item.Name,
                        d_date,
                        item.Attendance,
                        "<button type='button' class='btn btn-info' onclick='showDetail(" + item.NIK + ");' >Detail</button>"
                    ]).draw();
                })
            }
        })

and its the result.

enter image description here

Source: Ask Javascript Questions

LEAVE A COMMENT