<wxs>语法
<wxs module="foo"> function dateFormat(time) { var date = getDate(time); var yy = date.getFullYear().toString(); var mm = (date.getMonth() + 1).toString(); if (mm.length < 2) { mm = '0'.concat(mm) } var day = date.getDate().toString(); if (day.length < 2) { day = '0'.concat(day) } return yy + "-" + mm + "-" + day; } module.exports = { dateFormat: dateFormat } </wxs>
js语法
dateFormate(time) { var date = new Date(time); var yy = date.getFullYear().toString(); var mm = (date.getMonth() + 1).toString(); if (mm.length < 2) { mm = '0'.concat(mm) } var day = date.getDate().toString(); if (day.length < 2) { day = '0'.concat(day) } return yy + "-" + mm + "-" + day; },
yyyy-mm-dd转时间戳
let num = Date.parse(e.detail.value.replace(/-/g, '/'))