```
let d1 = new Date()
let year = d1.getFullYear();
let mon = d1.getMonth();
let day = d1.getDate();
let hour = d1.getHours(); //得到小时数
let minute = d1.getMinutes() ; //得到分钟数
let second = d1.getSeconds(); //得到秒数
let date = year + "-" + (mon < 10 ? "0" + (mon+1) : mon ) + "-" + (day < 10 ? "0" + day : day );
let time = (hour < 10 ? "0" + hour :hour) + ":" + (minute < 10 ? "0" + minute : minute ) + ":" + (second < 10 ? "0" + second : second );
// 设置日期、时间
this.setData({"node2Date" : date,"node2Time" : time,});
```