JS有自带的日期函数,获取如下:var date = new Date()var year = date.getFullYear()//获取年份var month = date.getMonth()+1//获取月份,因为是从0-11所以要+1var day = date.getDate()//获取天数var hour = date.getHours()//获取小时var minute = date.getMinutes()//获取分钟var second = date.getSeconds()//获取秒具体如下: