zoukankan      html  css  js  c++  java
  • js 计算自己多大了 打怪升级之路 二

    计算自己从出生到现在过了多少天

    <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岁

    <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)+min

  • 相关阅读:
    异常、中断、陷阱
    BigDecimal
    事务
    jsp的九大内置对象
    timer和ScheduledThreadPoolExecutor
    关于Python的导入覆盖解决办法
    RTTI
    Golang不会自动把slice转换成interface{}类型的slice
    Python中下划线的5种含义
    Python如何合并两个字典
  • 原文地址:https://www.cnblogs.com/liuqun/p/12655207.html
Copyright © 2011-2022 走看看