-1

可能重复:
有没有办法改变输入类型=“日期”的格式?

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

4

1 回答 1

0

我认为是这样,在 HTML 中没有 DD-MM-YYYY 格式的语法。请参阅此页面。它会对你有所帮助。或者你可以在 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>
于 2012-09-14T21:28:25.230 回答