- 当前 Bug 的表现(可附上截图)
- 预期表现
Year:2019
- 复现路径
- 提供一个最简复现 Demo
function addYear(sdate, syear) {
console.log('curDate:' + sdate)
var year = sdate.getFullYear()
console.log('Year:' + year)
var month = sdate.getMonth() + 1
var day = sdate.getDate()
var hour = sdate.getHours()
var minute = sdate.getMinutes()
var second = sdate.getSeconds()
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
要用 var year =(new Date(sdate)).getFullYear()这样子吗?是不是不能识别Date类型的参数需要强制转换一下?