• 时间日期Date类型


    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
    
        <script>
            /*push和pop为堆栈后进先出LIFO,unshift和shift为队列先进先出FILO*/
            var colors = ["red", "blue", " _", "yellow"];
            // alert(typeof colors.toString()); //String
            // alert(typeof colors.valueOf()); //Object
            // alert(typeof colors); //Object
            //alert(colors.join("|"));
            // var count = colors.push("black", "green");
            // var item = colors.pop();
            var shift = colors.shift();
            var unshift = colors.unshift("aaa", "bbb");
            //alert(item);
            //alert(colors);
            //alert(shift); //取出第一个red
            // alert(colors);
    
    
            /*// var values = [1, 2, 3, 4, 5];
            // alert(values.reverse());
            /*数组中已经存在两个可以直接用来重排序的方法:reverse()和sort()。
                reverse()不能很好对
            */
            function compare(value1, value2){
                if(value1 < value2){
                    return -1;
                }else if(value1 > value2){
                    return 1;
                }else{
                    return 0;
                }
            }
            var values = [3, 4, 1, 5 ,2, -1, -2, -4, 10, 15];
            //values.sort(compare).reverse();
            // alert(values);
            //alert(values.reverse());
            //alert(values);*/
    
            
            // var y2k = new Date(Date.UTC(2000, 0));
            // var allFives = new Date(Date.UTC(2005, 4, 5, 17, 55, 55));
            // //var someDate = new Date(Date.parse("May 25, 2015"));
            // alert(y2k);
            // alert(allFives);
    
    
            var date = new Date();
            function DateDemo(){   
    
                var day;
                var x = ["星期日", "星期一", "星期二", "星期三","星期四", "星期五", "星期六"];
                //var d = new Date();
                  day = date.getDay();   
                  return(x[day]);
              }
    
    
              function TimeDemo(){
                      var h, m;
                      var t = ["上午", "下午"];
                      h = date.getHours();
                      m = h -12;
                      return m ? t[1] : t[0];    
              }
            
            alert(date.getFullYear() + "-" + (date.getMonth() + 1) 
                + "-" + date.getDate() + " " + DateDemo() + " " + TimeDemo() 
                + " " +date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds());
    
    
    
    
    
    
    function DateDemo(){   
    
                var day;
                var x = ["星期日", "星期一", "星期二", "星期三","星期四", "星期五", "星期六"];
                //var d = new Date();
                  day = date.getDay();   
                  return(x[day]);
              }
    
    
    var date = new Date();
    alert(date.toLocaleString());
    // alert(date.toString());
    // alert(date.toDateString());
    // alert(date.toTimeString());
    alert(date.toLocaleDateString() + DateDemo() + date.toLocaleTimeString()  );
    
    
    
    
        </script>
    </body>
    </html>
  • 相关阅读:
    GitHub 更新fork的代码
    robotframework出现错误:Keyword 'AppiumLibrary.Open Application' expected 1 to 2 non-keyword arguments,got 5.
    adb命令积累
    appium测试android环境搭建(win7)
    小明的自留地
    转载:appium踩过的坑
    junit3和junit4的使用区别如下
    Python线程指南
    实现ie低版本支持input type="number"
    LODOP打印开发
  • 原文地址:https://www.cnblogs.com/double405/p/5087388.html
Copyright © 2020-2023  润新知