zoukankan      html  css  js  c++  java
  • 内置对象-Date

    1、数据格式:
    1)1576379936179 毫秒数
    2)Sun Dec 15 2019 11:18:56 GMT+0800 (中国标准时间)
    3)2019/12/15 11:21
    4)2019-12-15 11:21
    2、获取当前时间:
    1)Date.now()  //返回格式:1576379936179 毫秒数
    2)new Date()  //返回格式:Sun Dec 15 2019 11:18:56 GMT+0800 (中国标准时间)
    3)new Date().toDateString()   //返回格式:Sun Dec 15 2019
    4)new Date().toTimeString()  //返回格式:1:18:56 GMT+0800 (中国标准时间)
    3、创建时间:
    1)给 new Date()  传递相应参数
    4、获取相关方法:
    new Date().getFullYear()
    new Date().getDay();   // 获取当前星期中的某一天,0-星期天 , 1-星期一,2-星期二,3-星期三,4-星期四,5-星期五
    new Date().getDate();  //日期 1-31    
           .getUTCDate() 
           .setDate()
           .setUTCDate()
    new.Date().getMonth() //获取月份 0-11
           .getUTCMonth() 
                .setMonth()
           .setUTCMonth()
    new Date().getHours();      // 0-23
    new Date().getMinutes();   // 0-59
    new Date().getSeconds(); // 0-59
    new Date().getTimeZzoneOffset() 获得本地时间与UTC时间的时差
    ---------------------------------------------------------------------
    2、获取某月的第一天
    var dd = new Date();
    var year = 2019;
    var month = 1;
    dd.setFullYear(year,month-1, 1);
    console.log(dd.getDay());
    3、获取某月的总天数
    var dd = new Date();
    var year = 2019;
    var month = 1;
    dd.setFullYear(year, month, 0);
    console.log(dd.getDate());
     
    ---------------------------------------------------
    时间库:http://momentjs.cn/
  • 相关阅读:
    统计学基础
    ip地址分类
    OSI七层协议与TCP/IP模型、三次握手与四次挥手
    计算机编码
    [HNOI2008]Cards
    P4309 [TJOI2013]最长上升子序列
    P3794 签到题IV
    P2605 [ZJOI2010]基站选址
    UVA10791
    P3825 [NOI2017]游戏
  • 原文地址:https://www.cnblogs.com/yuyedaocao/p/10268369.html
Copyright © 2011-2022 走看看