zoukankan      html  css  js  c++  java
  • 设置日期格式(input新属性)适用于chrome 360 qq浏览器,但是对于firefox和ie却不适用

    <!DOCTYPE HTML>
    <html>
    <body>
    <form action="/example/html5/demo_form.asp" method="get">
    日期和时间:<input type="datetime-local" name="user_date" value="2015/03/27 10:41" id="user_date"/>
    <input type="submit" />
    </form>
    </body>
    </html>


    或者以下这么写代码:

    <html>

    <title>Test_datetime_local</title>

    <body>

     datatime-local:<input type="datetime-local" id="mydatetime-local"/>

    <br>date:<input type="date" id="mydate"/>

    <br>week:<input type="week" id="myweek"/>

    <br>month:<input type="month" id="mymonth"/>

    <br>time:<input type="time" id="mytime"/>

    <br>datetime:<input type="datetime" id="mydatetime"/>

    <p>Click the button and set the local datetime</p>

    <button onclick="myFunction()">Click here</button>

    <p id="demo"></p>

    <script>

    function myFunction(){

        var x=document.getElementById("mydatetime-local").value;

        year=x.substring(0,4);

        month=x.substring(5,7);

        day=x.substring(8,10);

        hour=x.substring(11,13);

        minute=x.substring(14)

        format=year+"-"+day+"-"+month;

        document.getElementById("demo").innerHTML = format;

    }

    </script>

    </body>

    </html>

    打开后结果如下:一般不要使用firefox或者IE,使用其他浏览器,如百度浏览器。因为其他浏览器可能存在问题,显示效果比较差。

    接下来设置日期,

    datetime-local 设置日期格式

     这个格式适用于chrome 360 qq浏览器,但是对于firefox和ie却不适用,为此我目前还没有找到合适的办法,求指教

  • 相关阅读:
    c++中for的四种用法
    同步
    排列算法(reverse...rotate...next_permutation)
    指针
    const的使用
    const_cast
    c++设计模式——单例模式
    c++中的流
    c++从string类型转换为bool类型
    结构体字节对齐方式
  • 原文地址:https://www.cnblogs.com/fgtt/p/6606043.html
Copyright © 2011-2022 走看看