浅时光吖~  
生活明朗,万物可爱,加油~

var now = new Date(); //当前时间

var nowYear = now.getFullYear(); //当前年

var nowMonth = now.getMonth() +1; //当前月(0-11,0代表1月)

var nowDate = now .getDate(); //当前日(1-31)

var weekArr = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")

var weekDay = weekArr[now.getDate()]  //当前星期

var nowHour = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();  //当前小时

var nowMinute = now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();  //当前分钟

var nowSecond = now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds(); //当前秒

var nowMilliseconds  = now.getMilliseconds(); //当前毫秒数(0-999)

var myDate = now.toLocaleDateString(); //获取当前日期

var mytime = now.toLocaleTimeString(); //获取当前时间

var myDayTime = date .toLocaleString( ); //获取日期与时间

posted on 2020-05-11 15:02  浅时光吖~  阅读(278)  评论(0编辑  收藏  举报