如何更改日期格式的Ajax codeigniter录制清单..?

时间:2018-12-06 11:36:05

标签: ajax codeigniter-3

如何在codeigniter ajax列表中更改日期格式。当我从使用ajax从数据库中获取记录时,我想将日期格式更改为DD / MM / YYYY。

查看页面列表代码:-

             for (i = 0; i < o.all2; i++)
                        {   

                            count2 += 1;
                            output2 += '<tr class="new_tr2">';
                            output2 += '<td>' + count2 + '</td>' +
                                    // '<td>' + o.activity2[i]['student_name'] +'</td>'+
                                    '<td>' + o.activity2[i]['name'] + '</td>' +
                                    '<td>' + o.activity2[i]['date_time'] + '</td>' +
                                    '<td>' + o.activity2[i]['note'] + '</td>' +
                                    '<td>' + res+ '</td>'+
                                    '<td>' +button+'</td>';
                            output2 += '</tr>';

                        }
                        $('#app4').append(output2);

enter image description here

1 个答案:

答案 0 :(得分:0)

我正在使用此javascript函数格式化日期。

function formatDate(date) {
    var d = new Date(date),
        month = '' + (d.getMonth() + 1),
        day = '' + d.getDate(),
        year = d.getFullYear();

    if (month.length < 2) month = '0' + month;
    if (day.length < 2) day = '0' + day;

    return [day, month, year].join('/');
}