1、js的Date对象
java里面获取当前时间
Date date = new Date();
//格式化
//DateFormat ddtf = DateFormat.getDateTimeInstance();
//System.out.println(ddtf.format(date));
js里date方法
var date = new Date() :js获取当前的时间
date.toLocaleString() :格式化 转换成习惯格式
getFullYear() :获取当前年份
getMonth() :获取当前的月份 // 返回(0~11)
getDay() :返回一周中的某一天 //(0-6)周日为0
getDate() :返回当前天
getHours() :获取当前小时
getMinutes() :获取当前的分钟
getSeconds() :获取当前秒
getTime() :获取从1970年1月1日至今毫秒数 //用来处理缓存(无缓存)
js的Math对象
Math中都是静态方法,可以接使用Math.方法
ceil(x) :向上取整
floor(x) :向下取整
round(x) :四舍五入
random() :得到随机数 (0.0~1.0伪随机数)
pow(x,y) : x的y次方
Math属性
PI、E、LN2、LN10、LOG2E、LOG10E、SQRT2、SQRT1_2 其值为 1/SQRT2