【问题标题】:html 5 date format [duplicate]html 5日期格式[重复]
【发布时间】:2012-09-08 01:03:56
【问题描述】:

可能重复:
Is there any way to change input type=“date” format?

我们能否更改 html 5 中输入的日期格式?目前,我的网站显示 MM-DD-YYYY,但我希望它显示 DD-MM-YYYY。

【问题讨论】:

    标签: html


    【解决方案1】:

    我想是的,在 HTML 中没有 DD-MM-YYYY 格式的语法。请参阅此page。对您有所帮助。或者您可以在 javascript 中尝试:

    <script language="JavaScript">
    <!-- Begin
    // Get today's current date.
    var now = new Date();
    // Array list of days.
    var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
    // Array list of months.
    var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
    // Calculate the number of the current day in the week.
    var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
    // Calculate four digit year.
    function fourdigits(number){
        return (number < 1000) ? number + 1900 : number;
                                    }
    // Join it all together
    today = days[now.getDay()] + ", " +
            months[now.getMonth()] + " " +
            date + ", " +
            (fourdigits(now.getYear())) ;
    // Print out the data.
    document.write(today);
    // End -->
    </script>
    

    【讨论】:

      猜你喜欢
      • 2014-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-16
      • 2021-05-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多