zoukankan      html  css  js  c++  java
  • Date : 日期对象

     一、如何创建日期对象
                    1. new Date()
                    2. new Date(year,month,date,hours,minutes,seconds)
                    3. new Date(year,month,date)
                二、如何获取日期时间?
                    1. 获取年份
                    date.getFullYear()
                    2. 获取月份
                    date.getMonth()
                    3. 获取日
                    date.getDate()
                    4. 获取星期
                    date.getDay()
                    5. 获取小时
                    date.getHours()
                    6. 获取分钟
                    date.getMinutes()
                    7. 获取秒钟
                    date.getSeconds()
                    8. 获取毫秒
                    date.getMilliseconds()
                    9. 获取时间戳
                    date.getTime()
                三、时间戳 : 从1970年1月1日0时整到现在的毫秒数。
                四、以本地格式的字符串显示日期时间
                    date.toLocaleString()
                    以本地格式的字符串显示日期
                    date.toLocaleDateString()
                    以本地格式的字符串显示时间
                    date.toLocaleTimeString()
                扩展五、设置日期时间
                    1. 设置年份
                    date.setFullYear()
                    2. 设置月份
                    date.setMonth()
                    3. 设置日
                    date.setDate()
                    4. 小时
                    date.setHours()
                    5. 分钟
                    date.setMinutes()
                    6. 秒钟
                    date.setSeconds()
                    7. 毫秒
                    date.setMilliSeconds()

     

  • 相关阅读:
    Python 元组
    Python 字典
    Python 列表
    Python 数字(函数)
    Python 序列操作符与函数(字符串)
    JavaScript使用IEEE 标准进行二进制浮点运算,产生莫名错误
    网站用户体验要点(翻译理论)
    去掉checkbox边框的方法
    WPF数据模板样式选择器
    JS中年份问题的纠结!
  • 原文地址:https://www.cnblogs.com/pppoe/p/10388935.html
Copyright © 2011-2022 走看看