首页 > Web开发 > 详细

js获取当前日期

时间:2020-08-25 11:25:54      阅读:83      评论:0      收藏:0      [点我收藏+]

获取时间

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();     //获取当前时间

js获取当前日期

原文:https://www.cnblogs.com/changx/p/13558333.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!