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/
  • 相关阅读:
    Nginx服务器中配置非80端口的端口转发方法详解
    索引的优缺点
    redis cluster搭建
    linux 无需主机密码传输文件
    linux buffer/cache手动释放
    常用的Percona-Toolkit工具
    mysql 存储过程批量删除表
    redis(方法通用)开机自启动
    mysql 查看表的分区信息
    redis 内存分析
  • 原文地址:https://www.cnblogs.com/yuyedaocao/p/10268369.html
Copyright © 2011-2022 走看看