js获取当前日期

获取时间

let time = new Date() 
let year = time.getYear();        //获取当前年份(2位)
let years = time.getFullYear();    //获取完整的年份(4位,1970-????)
let month = time.getMonth();       //获取当前月份(0-11,0代表1月)
let day = time.getDate();        //获取当前日(1-31)
let week = time.getDay();         //获取当前星期X(0-6,0代表星期天)
let times = time.getTime();        //获取当前时间(从1970.1.1开始的毫秒数)
let hours = time.getHours();       //获取当前小时数(0-23)
let minutes = time.getMinutes();     //获取当前分钟数(0-59)
let seconds = time.getSeconds();     //获取当前秒数(0-59)
let ms = time.getMilliseconds();    //获取当前毫秒数(0-999)
let Dates = time.toLocaleDateString();     //获取当前日期
let Times = time.toLocaleTimeString();     //获取当前时间

posted on 2020-08-25 10:36  白黑besos  阅读(852)  评论(0编辑  收藏  举报

导航