Date的各种使用方法

Date对象方法:

首先得先创建一个时间对象 new Date()

get系列:

getDate() 返回一个月中的某一天(1-31)

getDay()    返回一周中的某一天(0-6)

getFullYear()  返回四位数的年份

getMonth()   返回月份(0-11 0是一月)

getHours()   返回的是当前的小时(0-23)

getMinutes()  返回的是当前的分钟(0-59)

getSeconds()  返回的是当前的秒(0-59)

getTime()    返回的是1970年1月1日至今的毫秒数

set系列:

parse()    返回1970年1月1日到指定日期的毫秒数

setDate()   设置一月的某一天(1-31)

setFullYear()  设置年份

setMonth()   设置月份(0-11)

setHours()    设置小时(0-23)

setMinutes()   设置分钟(0-59)

setSeconds()  设置秒数(0-59)

setTime      以毫秒数设置Date

猜你喜欢

转载自blog.csdn.net/weixin_43627806/article/details/89880666