zoukankan      html  css  js  c++  java
  • date函数

     

        setDate() / getDate();   从Date对象中返回一个月中的某一天(1~31)
    getDay();   从Date对象返回一周中的某一天(0~6)
    set / getMonth(); 从Date对象中返回月份(0~11)
    set / getFullYear();   从Date对象以四位数返回年份
    set / getHours(); 返回Date对象的小时(0~23)
    set / getMinutes();   返回Date对象的分钟(0~59)
    set / getSeconds();   返回Date对象的秒数(0~59)
    set / getMilliseconds();   返回Date对象的毫秒
    set / getTime();   返回1970年1月1日至今的毫秒数

    var d = new Date()   //当前时间
    var d = new Date("2020/11/11 10:11:12")
    var d = new Date("2022-11-11 10:11:12")
    var d = new Date(2019, 3, 21, 10, 11, 12)   // month: 0~11
    var d = new Date(1553134272123)  

    var d = new Date(2019, 2, 21, 10, 11, 12, 123) console.log(d.getDate()) // 21日 console.log(d.getMonth()) // 2(3月份) console.log(d.getFullYear()) // 2019年 console.log(d.getHours()) // 10 console.log(d.getMinutes()) // 11 console.log(d.getSeconds()) // 12 console.log(d.getMilliseconds()) // 123

    console.log(d.getTime())  // 1553134272123 毫秒
    console.log(d.getDay()) // 星期几, 0~6,0表示星期天

    console.log(d.toDateString()) //Thu Mar 21 2019
    console.log(d.toLocaleString()) //2019年3月21日 上午10:11:12
    console.log(d.toLocaleDateString()) //2019年3月21日
    console.log(d.toLocaleTimeString()) //上午10:11:12

     

  • 相关阅读:
    C++内存检测函数_CrtSetBreakAlloc()
    Detours 的配置
    浅析杀毒软件开发原理
    Sqlite3初学
    java拦截器、过滤器的区别
    sudo 设置无需密码
    Visual Studio 2012/2010/2008 远程调试
    jquery 随笔
    网页中显示xml,直接显示xml格式的文件
    centos7.2_x64安装mysql.tar.gz
  • 原文地址:https://www.cnblogs.com/Deaseyy/p/10859780.html
Copyright © 2011-2022 走看看