zoukankan      html  css  js  c++  java
  • 时间日期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>
  • 相关阅读:
    常用颜色
    在VS2010中打开VS2012的项目
    vs2012 断点不能调试
    Setup Factory 打包.netframework 2.0
    Access 中数据库操作时提示from子句语法错误
    vs2012 .netFramwork2.0发布到xp
    c# access插入null值
    Visual Studio安装卸载模板
    Codeforces 455D
    ACdream 1157 (cdq分治)
  • 原文地址:https://www.cnblogs.com/double405/p/5087388.html
Copyright © 2011-2022 走看看