設置日期格式(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卻不適用,為此我目前還沒有找到合適的辦法,求指教

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM