Date,Math对象

1.Date

1>创建
var d = new Date(); //返回当前执行时间
var d2 = new Date("2/3/2021 11:10:1"); //指定时间

2>getDate() : 返回当前对象的日
d2.getDate() //3

3>getDay() : 返回周几,0-6,周日为0
d2.getDay()

4>getMonth() : 返回月,0-11,一月为0
5>getFullYear() : 返回年份
6>getTime() : 返回当前日期时间戳

时间戳:从标准时间1970.1.1 0:0:0,到当前日期所花费的毫秒数(1s =1000ms)

7>Date.now() : 获取当前时间戳

2.Math
Math.abs()
Math.ceil() //上取整
Math.floor()
Math.round() //四舍五入
Math.random() //0-1随机数
Math.max(1,2,3)
Math.min()
Math.pow(x,y); //x的y次幂
Math.sqrt(x); //x的平方根

你可能感兴趣的:(javascript)