JavaScript之Math

1. Math

Math是js的内置函数,无需创建,把Math作为对象使用就可以调用其属性和方法。

2.Date

   2.1 日期对象创建

var now = new Date ( );

含参数时表示距离1970年1月1日的毫秒数。

   2.2 日期处理

oDate.getDate()          返回一个月中的某一天 (1 ~ 31)

 oDate.getDay()          返回一周中的某一天 (0 ~ 6)

 oDate.getMonth()       返回月份 (0 ~ 11)

 oDate.getFullYear()    以四位数字返回年份

oDate.getHours()                       返回当前小时(0-23)

oDate.getMinutes()                    返回当前分钟 (0 ~ 59)

oDate.getSeconds()                   返回当前秒(0 ~ 59)

oDate.getMillisenconds()           返回当前毫秒(0 ~ 999)

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

oDate.setDate()                         设置月中的某一天 (1 ~ 31)

 oDate.setMonth()                      设置月份 (0 ~ 11)

 例:oDate.setMonth(9);   alert(oDate.getMonth())

oDate.setFullYear()                    设置年份(四位数)

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

oDate.setMinutes()                    设置分钟 (0 ~ 59)

oDate.setSeconds()                   设置秒(0 ~ 59)

oDate.setMillisenconds()          设置毫秒(0 ~ 999)

oDate.setTime()                         设置1970年1月1日至今的毫秒数

原文地址:https://www.cnblogs.com/a-peppa-pig/p/9460166.html