js对时间的一些操作

new Date()  //Thu Dec 27 2018 12:16:16 GMT+0800 (中国标准时间);

new Date('2018-1-1,12:20:20'/1258454512000)  //转换时间格式的字符串或者1970到现在的毫秒数 为中国标准时间

new Date().getHours() // 获取当前时间的小时 类型为数字

new Date().getMinutes() // 获取当前时间的分钟 类型为数字

new Date().getSeconds() // 获取当前时间的秒 类型为数字

new Date().getDay() // 获取本周的星期 类型为数字 星期日为0

new Date().getFullYear() // 获取本周的星期 类型为数字 星期日为0

猜你喜欢

转载自www.cnblogs.com/luoshida/p/10184237.html