javascript数组日期

arr

forEach(callback,thisArg)

thisArg:指明回调函数的this指向

callback(element,index,arr)

element:每次取到的数组元素值

index:遍历数组每次取到的数组元素索引

arr:操作的数组

  • every():测试所有的元素都通过了测试

    var arr3 = ['1','2','3','4'];
           var result  = arr3.every(function(value) {
               return value < 5
          });
           console.log(result);

     

  • some():有一个满足条件的就返回true

date

// 参数指定

var date2 = new Date(year,month);

console.log(date2);

// 指定事件日期的字符串,字符串格式多样

var date3 = new Date("2019-05-05");

console.log(date3);

// 根据毫秒指定

Date.now(); // 到现在经过了多少毫秒

var date4 = new Date(Date.now());

console.log(date4);

  • 本地标准时间:当前所处时区的标准时间

  • 世界标准时间:UTC(格林威治时间)GMT(精度高)

Date.parse(日期字符串):返回从1970--1-1 0:0:0 到该日期的毫秒数

getDate():返回一周中的第几天,周日是0

getMonth():返回月份,1月是0

 

 

posted @ 2019-05-05 09:47  Chesney张帅  阅读(750)  评论(0编辑  收藏  举报