1. 程式人生 > >[轉]EasyUI 日期格式

[轉]EasyUI 日期格式

data Matter utf default spa mbo char nth css

本文轉自:http://www.jeasyui.net/demo/512.html

Different date formats are applied to different DateBox components.

源代碼
    1. <!DOCTYPE html>
    2. <html>
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>Date Format - jQuery EasyUI Demo</title>
    6. <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
    7. <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
    8. <link rel="stylesheet" type="text/css" href="../demo.css">
    9. <script type="text/javascript" src="../../jquery.min.js"></script>
    10. <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
    11. </head>
    12. <body>
    13. <h2>Date Format</h2>
    14. <p>Different date formats are applied to different DateBox components.</p>
    15. <div style="margin:20px 0;"></div>
    16. <input class="easyui-datebox"></input>
    17. <input class="easyui-datebox" data-options="formatter:myformatter,parser:myparser"></input>
    18. <script type="text/javascript">
    19. function myformatter(date){
    20. var y = date.getFullYear();
    21. var m = date.getMonth()+1;
    22. var d = date.getDate();
    23. return y+‘-‘+(m<10?(‘0‘+m):m)+‘-‘+(d<10?(‘0‘+d):d);
    24. }
    25. function myparser(s){
    26. if (!s) return new Date();
    27. var ss = (s.split(‘-‘));
    28. var y = parseInt(ss[0],10);
    29. var m = parseInt(ss[1],10);
    30. var d = parseInt(ss[2],10);
    31. if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
    32. return new Date(y,m-1,d);
    33. } else {
    34. return new Date();
    35. }
    36. }
    37. </script>
    38. </body>
    39. </html>

[轉]EasyUI 日期格式