标签:round time 取整 and date 方法 mon int parse
var time = new Date();
var year = time.getFullYear();
年份输出
var second = time.getSeconds();
秒的输出
var moth = time.getMonth()+1;
月份的输出
var day = time.getDay();
星期几
var day = time.getDate();
哪一天
document.write(time);
var rand = Math.random();
random 是随机数的意思
document.write(rand);
var arr = ["张三","李四","王五","赵六","七七"]
var shuzi =rand*arr.lenght;
document.write(shuzi);
是0到1的数,也就是概率
shuzi = parseInt(shuzi);
取整
document.write(arr[shuzi]);
随机数的转换
var i = 1.1;
i = math,round(i);
document.write
四舍五入
var i = 1.1;
i = Math.ceil(i);
向上取整
i = Math.floor(i);
向下取整
document.write(i);
标签:round time 取整 and date 方法 mon int parse
原文地址:http://www.cnblogs.com/yunpeng521/p/6881992.html