var tableTools = new $.fn.dataTable.TableTools(dataTable_leads,{
'sSwfPath': '//cdn.datatables.net/tabletools/2.2.4/swf/copy_csv_xls_pdf.swf',
aButtons: [
{ sExtends: "csv",
sFileName: 'GlData_' + updateTime() + '.csv',
sButtonText: "<i class='fa fa-file-text'></i>",
mColumns: [ 0, 1, 2, 3, 4 ]
},
{ sExtends: "xls",
sFileName: 'GlData_' + updateTime() + '.xls',
sButtonText: "<i class='fa fa-file-excel-o'></i>",
mColumns: [ 0, 1, 2, 3, 4 ]
},
{ sExtends: "pdf",
sFileName: 'GlData_' + updateTime() + '.pdf',
sButtonText: "<i class='fa fa-file-pdf-o'></i>",
mColumns: [ 0, 1, 2, 3, 4 ]
}
]
});
function updateTime()
{
var currentDate = new Date()
var day = currentDate.getDate()
var month = currentDate.getMonth() + 1
var year = currentDate.getFullYear()
var d = day + "-" + month + "-" + year;
var hours = currentDate.getHours() < 10 ? "0" + currentDate.getHours() : currentDate.getHours();
var minutes = currentDate.getMinutes() < 10 ? "0" + currentDate.getMinutes() : currentDate.getMinutes();
var seconds = currentDate.getSeconds() < 10 ? "0" + currentDate.getSeconds() : currentDate.getSeconds();
var t= hours + " " + minutes + " " + seconds;
var x = d + " " + t;
return x;
}
我想添加一个带有文件名保存的时间戳。这里updatetime工作正常,并附加文件名。但是5分钟后,时间也保持不变,它没有改变。系统时间会改变,但在这里它不会改变。刷新页面时,只有在保存时间戳时间时才会更改。如何解决这个问题?请帮帮我