math 属性
1:math.ramdon()[0,1)的随机数
2:math.ceil().向上取整
3:math.floor()向下取整
4:math.abs().求绝对值
5:math.round()四合五入(-1.5是-1大)
6:math.mix(1,234,5,5)最大值
7:math.min()最小值
date()属性
var oppo=new date()
oppo.getdate(2012,5,20,10,0,0);当前时间
oppo.getFullyear().年数
oppo.getYear()年数、千年虫
oppo.getMonth() 一般加一的;
oppo.getDay().星期数(0-6);0为星期天
oppo.getSeconds()
oppo.getMinutes()
一段代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
/// var="abc/123adc";//Nan
// var num =1.2;
// document.write(praseInt(num)+"</br>")//多了转化.不知是不是数字用,确定是数字就用math.
// document.write(Math.ceil(num)+"</br>")
// document.write(Math.floor(num)+"</br>")
// document.write(Math.round(num)+"</br>")//round 向上取证.四舍五入
// document.write(Math.abs(num)+"</br>")
// document.write(Math.max(1,2,3,4)+"</br>")
// document.write(Math.min(1,2,3,4,5)+"</br>")
// document.write(Math.random()*2+1+"</br>")
// var oDate1=new Date("1970,0,1,8,0,0,");//
// var oDate=new Date();
// oDate.setFullYear("2019");
// oDate.setHours("25");
// document.write(oDate)
// document.write(oDate.getDate())//0~6;
// document.write(oDate.getDay())//0~6;只会是数字.0对应星期天;
// document.write(oDate.getMonth())
// document.write(oDate.getYear())//118千年虫..
// document.write(oDate.getFullYear())
// document.write(oDate.getHours())
// document.write(oDate.getSeconds())
// document.write(oDate.getSeconds())
// document.write(oDate.getTime())//距离1970年的毫秒值
// document.write(oDate1.getTime())
//距离21明天早上十点倒计时;
//2018年6月20日星期几,几点几分几分几秒
// window.onload=function(){
// var time=new Date(2018,5,21,10,0,0);
// var body =document.getElementsByTagName('body')[0];
// var strat=setInterval(function(){
// body.innerHTML="";
// now=new Date();
// minus=time.getTime()-now.getTime();
// day=Math.floor(minus/86400000);
// hours=Math.floor(minus%86400000/3600000);
// minutes=Math.floor(minus%86400000%3600000/6000);
// seconds=Math.floor(minus%86400000%3600000%6000/1000);
// milliseconds=Math.round(minus%86400000%3600000%6000%1000/100);
// body.innerHTML=day+'天'+hours+'小时'+minutes+'分钟'+seconds+'.'+milliseconds+'秒'; },100)
// // }
function timer(){
var now = new Date();
var later= new Date(2018,5,21,10,0,0);
var answer=later.getTime()-now.getTime();
var day=parseInt(answer/(60*60*24*1000));
var hours=parseInt(answer%(60*60*24*1000)/(60*60*1000));
var minutes=parseInt(answer%(60*60*24*1000)%(60*60*1000)/(60*1000));
var seconds=parseInt(answer%(60*60*24*1000)%(60*60*1000)%(60*1000)/100)/10;
var body=document.getElementsByTagName('body')[0];
body.innerHTML="";
body.innerHTML=day+'天'+hours+'小时'+minutes+'分钟'+seconds+'秒'
// // document.write(day+'天'+hours+'小时'+minutes+'分钟'+seconds+'秒')
//
}
setInterval(timer,100)
//2018年6月20日星期几,几点几分几分几秒
function time() {
var now = new Date();
now1 = now.getFullYear();
now2 = now.getMonth()+1;
now3 = now.getDate();
now4 = now.getHours();
now7=now.getDay();
now5 = now.getMinutes();
now6 = now.getSeconds();
var body=document.getElementsByTagName('body')[0];
body.innerHTML="";
if(now4<=12){ body.innerHTML=now1+'年'+now2+'月'+now3+'日'+' '+'星期'+now7+' '+now4+'AM'+' '+now5+'分'+now6+'秒'}
else{body.innerHTML=now1+'年'+now2+'月'+now3+'日'+' '+'星期'+now7+' '+now4+'PM'+' '+now5+'分'+now6+'秒'}
}
setInterval(time,1000)
</script>
</body>
</html>