Data时间管理大全

data是一个比较常用的功能,使用它一般通过var now = new Data();对象,对对象取值now.getFullYear();

var now = new Date();

now; // Wed Jun 24 2015 19:49:22 GMT+0800 (CST)

getFullYear(); // 2015, 年份
getMonth(); // 5, 月份,注意月份范围是0~11,5表示六月
getDate(); // 24, 表示24号
getDay(); // 3, 表示星期三
getHours(); // 19, 24小时制
getMinutes(); // 49, 分钟
getSeconds(); // 22, 秒
getMilliseconds(); // 875, 毫秒数
getTime(); // 1435146562875, 以number形式表示的时间戳

一定注意其中的月份是0-11表示对应的1-12
月份+1才是当前月份

posted @ 2018-03-28 17:31  Kaso基佬康  阅读(100)  评论(0编辑  收藏  举报