Date 日期对象

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()

原文地址:https://www.cnblogs.com/huhuhuhuhuhu/p/10375751.html