// JS获取两个日期之间相差的天数 function getDaysBetween(dateString1, dateString2) { var startDate = Date.parse(dateString1) var endDate = Date.parse(dateString2) var days = (endDate - startDate) / (1 * 24 * 60 * 60 * 1000) // alert(days); return days }
// 日期格式化 function formatDate(cellValue) { if (cellValue === null || cellValue === '') return '' var date = new Date(cellValue) var year = date.getFullYear() var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1 var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() return year + '-' + month + '-' + day }