• date+math


    一、创建日期对象

    var datr= new Date();

    1创建指定日期时间对象
    var date=new Date("1999-09-09 11:11:11");

       alert(date);
    2获取指定年月日时间对象
        外国人:月份0-11
        星期:7123456*/
       var d=new Date(2018,8,9);
       alert(d);

    3获取当前系统日期时间对象
        var date=new Date(); //自带字符串
        //获取年
        var year=date.getFullYear();//自带返回值
        //获取月
        var month=date.getMonth()+1;
        //获取日
        var day=date.getDate();
        /*获取星期*/
        var week=date.getDay();

    判断外国周日
        if(week!==0){
            console.log(year+"年"+month+"月"+day+"日 星期"+week);
        }
        else{
            console.log(year+"年"+month+"月"+day+"日 星期天"+week);
        }
        //获取小时
        var hour=date.getHours();
        //获取分钟
        var minute=date.getMinutes();
        //获取秒
        var seconds=date.getSeconds();
        console.log(year+"年"+month+"月"+day+"日 星期"+week+""+hour+":"+minute+":"+seconds);

    二、math

        //求绝对值
        document.write(Math.abs(-9));
        document.write("<br>");
        //向上取整
        document.write(Math.ceil(12.1));
        //13个商品,每页显示三条,总页数=math.ceil(13/3)
        document.write("<br>");
        //向上取整
        document.write(Math.floor(12.9));
        document.write("<br>");
        //取三者最大值
        document.write(Math.max(Math.max(1,2),3));
        document.write("<br>");
        //取最小值
        document.write(Math.min(1,2));
        document.write("<br>");
        //求次幂
        document.write(Math.pow(2,3));//水仙花数
        document.write("<br>");
        //随机产生0-9之间的数字
        document.write(Math.random());
        //平方根
        document.write("<br>");
        document.write(Math.sqrt(16));

  • 相关阅读:
    fastjson 简单使用 及其JSONObject使用
    HttpClient 的使用
    python操作excel xlwt (转)
    matplotlib 设置标题 xy标题等
    matplotlib 饼状图
    Mac下面 matplotlib 中文无法显示解决
    matplotlib 折线图
    matplotlib条形图
    matplotlib直方图
    python matplotlib配置
  • 原文地址:https://www.cnblogs.com/a199706/p/11110825.html
Copyright © 2020-2023  润新知