常用的内置对象
創建Date對象方法
| new Date() |
| new Date(month dd,yyyy hh:mm:ss) |
| new Date(yyyy,mth,dd,hh,mm,ss) |
| new Date(yyyy,mth,dd) |
| new Date(ms) |
Date對象獲取時間細節方法:
| getDate() | 從Date對象返回一個月中的某一天(1~31) |
| getDay() | 從Date對象返回一周中的某一天(0~6) |
| getMonth() | 從Date對象返回月份(0~11) |
| getFullYear() | 從Date對象以四位數字返回年份 |
| getHours() | 返回Date對象的小時(0~23) |
| getMinutes() | 返回Date對象的分鐘(0~59) |
| getSeconds() | 返回Date對象的秒數(0~59) |
| getTime() | 返回1970年1月1日至今的毫秒數 |
Date對象設置時間的方法:
| setDate() | 設置Date對象中月的某一天(1~31) |
| setMonth() | 設置Date對象中月份(0~11) |
| setFullYear() | 設置Date對象中的年份(四位數字) |
| setHours() | 設置Date對象中的小時(0~23) |
| setMinutes() | 設置Date對象中的分鐘(0~59) |
| setSeconds() | 設置Date對象中的秒鐘(0~59) |
| setMilliseconds() | 設置Date對象中的毫秒(0~999) |
Math對象的常用方法:
| abs(x) | 返回數的絕對值 |
| ceil(x) | 對數進行上舍入 |
| floor(x) | 對數進行下舍入 |
| max(x,y) | 返回x和y中的最高值 |
| min(x,y) | 返回x和y中的最低值 |
| pow(x,y) | 返回x的y次冪 |
| random() | 返回0~1之間的隨機數 |
| round(x) | 把數四舍五入為最接近的整數 |
| sqrt(x) | 返回數的平方根 |
轉載于:https://www.cnblogs.com/sy130908/p/11161655.html
總結
- 上一篇: 【模板】单源最短路径(弱化版)
- 下一篇: determination