自定义自己的时间

  var endTime = new Date(“2015/12/12”);  

  如果Date 括号里面写日期  就是 自己定义的时间  

  如果 Date括号里面不写日期 , 就是当前时间 。

  new Date(“2015/12/12 17:30:00”);

  日期和时分秒中间 有空格隔开

    var date = new Date();
    console.log(date);  // 得到的是现在的时间
    date = new Date("2015/12/12");
    console.log(date);  // Sat Dec 12 2015 00:00:00 GMT+0800 (中国标准时间)
    date = new Date(2018,4,12); //Sat May 12 2018 00:00:00 GMT+0800 (中国标准时间)
    console.log(date);

猜你喜欢

转载自www.cnblogs.com/ustc-yy/p/12074577.html