/*** 获取当前时间戳(秒)*/function getNowSceond(){return Math.floor(Date.now() / 1000);}/*** 根据时间戳获取年,月,日,时,分,秒* @param {*} nTimeStamps */function getTimeInfo(nTimeStamps) {//转毫秒var date = new Date(nTimeStamps * 1000);//返回数据var retData = {nYear: date.getFullYear(),nMonth: date.getMonth() + 1,nDay: date.getDate(),nHour: date.getHours(),nMinutes: date.getMinutes(),nSeconds: date.getSeconds()};return retData;}//当前时间戳var curTimeStamps = getNowSceond();//时间戳转对象var timeInfo = getTimeInfo(curTimeStamps);//输出日志console.log("timeInfo=%s",JSON.stringify(timeInfo)); //输出:timeInfo={"nYear":,"nMonth":12,"nDay":16,"nHour":14,"nMinutes":17,"nSeconds":18}
700字范文,内容丰富有趣,生活中的好帮手!