JS calculate the time difference, export excel

The calculated difference obtained getTime properties ms

var dateEnd = new new a Date (res.endtime.replace (G //, "/")); // the - into / using a Date new new 
var dateBegin = new new a Date (); // get the current time 
var DateDiff = dateEnd.getTime () - dateBegin.getTime (); // number of milliseconds time difference 
var hours = Math.floor (DateDiff / (3600 * 1000)); // calculate the difference h

JS plug-ins to achieve export excel

Links to download the document: https://fly.layui.com/extend/excel/

// , export excel plugin 
    function exportTable (ID) {
         var domstr = '', tbName = 'test' ; 
        domstr + = $ ( '#' + ID + 'tableHead') HTML () Replace (/ <TH> /.. G, '<TD>') Replace (/ <\ / TH> / G, '</ TD>'. ); 
        domstr + = $ ( '#' + ID + 'tableText' ) .html (); 
        Document. the getElementById ( 'exportExcel') = the innerHTML. domstr;
         // Get a head and body html tables derived directly 
        var Data = LAY_EXCEL.tableToJson (document.getElementById ( 'exportExcel')); // or $ ( '# LAY-EXPORT- the TEST ') 
        the console.log (Data);
        was export data = [];
        exportData.push.apply(exportData, data.head);
        exportData.push.apply(exportData, data.body);
        LAY_EXCEL.exportExcel(exportData, tbname + '统计表格'+ new Date().toLocaleString() +'.xlsx', 'xlsx')

Jquery url needs to be introduced with the excel.min.js

 

Guess you like

Origin www.cnblogs.com/nixindecat/p/11245189.html