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>
  • 相关阅读:
    用GD库生成高质量的缩略图片[转载]
    Linux流量监控工具 iftop (最全面的iftop教程)
    数据库开发数据库使用连接池
    过去时的那些硬件和软件
    关于及时回收(GC)系统资源的析构对象的的示例
    控制好节奏,踏实做好每件事
    如何管理IIS,自动创建WEB SITE,应用程序池
    数据库开发数据库的Data Base connection 简单池功能启示
    .Net MSMQ在分布式中的应用
    高并发高负载网站的系统架构注意的问题
  • 原文地址:https://www.cnblogs.com/double405/p/5087388.html
Copyright © 2011-2022 走看看