美文网首页
date对象

date对象

作者: 青春前行 | 来源:发表于2017-08-24 12:44 被阅读0次

    1、 var date = new Date();//获取当前的时间
    date.getFullYear()//年
    date.getMonth()//月,获取当前月份(0-11,0代表1月)
    date.getDate()//日
    date.getDay()//星期,获取当前星期X(0-6,0代表星期天)
    2、获取之前一个月的星期
    var beforedate = new Date(date.getFullYear(),date.getMonth()+1,date.getDate());
    beforedate.getDay()//获取的是下个月这一天的星期几
    也就是再将new Date()中传三个参数。

    相关文章

      网友评论

          本文标题:date对象

          本文链接:https://www.haomeiwen.com/subject/ogasdxtx.html