首页 > Web开发 > 详细

JS工具对象 DATE 方法

时间:2017-04-03 14:07:31      阅读:290      评论:0      收藏:0      [点我收藏+]

1.获取当前电脑的系统时间   var time = new Date();

var time = new Date();//获取当前系统时间
console.log(time); // Mon Apr 03 2017 09:03:18 GMT+0800 (中国标准时间)

2.获取当前年    time.getFullYear();

var time = new Date();
var year = time.getFullYear();
console.log(year);//2017

3.获取当前月   time.getMonth();

var time = new Date();
var month = time.getMonth();
console.log(month); //3

4.获取当前天 time.getDate();

var time = new Date();
var day = time.getDate();
console.log(day);3

5.获取当前 (0-6代表周日-周六)time.getDay();

var time = new Date();
var week = time.getDay();
console.log(week); //  1  (结果 0-6 周日、周一、周二...周六 )

6.获取当前时间(当前小时整点) time.getHours();

var time = new Date();
var hours = time.getHours();
console.log("hours   "+hours);//  10

7.获取当前分钟(分钟) time.getMinutes();

var time = new date();
var minutes = time.getMinutes();
console.log(minutes); //34

8.获取当前秒 time.getSeconds();

var  time = new date();
var  seconds = time.getSeconds();
console.log(seconds);

9.获取当前毫秒 time.getMilliseconds();

var time = new Date();
var mlSeconds = time.getMilliseconds();
console.log("miSeconds       "+mlSeconds);//  519

10.

JS工具对象 DATE 方法

原文:http://www.cnblogs.com/zzzzzzzsy/p/6661747.html

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