计算本身从出生到如今过了多少天dom
<script> /** * 计算本身活了多少天 */ //1)建立如今的日期对象,取出当前的毫秒值 var today = new Date(); var time = today.getTime(); //2)建立出生日期的时期对象,取出那时的毫秒值 var yestoday = new Date("1996/03/19"); var times = yestoday.getTime(); //3)两个毫秒值相减 var str = (time-times)/1000/3600/24; document.write("张三已通过了<font color='red'>"+str+"</font>天了"); </script>
计算本身再活了多少天,能到100岁ide
<script> /** * 计算本身再活了多少天,能到100岁 */ //1)建立如今的日期对象,取出当前的毫秒值 var today = new Date(); var time = today.getTime(); //2)建立未来日期的时间对象,取出那时的毫秒值 var yestoday = new Date(1996+100,3,19); var times = yestoday.getTime(); //3)两个毫秒值相减 var str = (times-time)/1000/3600/24; document.write("张三还差<font color='red'>"+str+"</font>天100岁"); </script>
求随机整数的公式 Math.random()*(max-min)+minspa