在 HTML 如何更改日期的格式?使用 date() 我得到了今天的日期。问题是我不知道如何更改日期的格式。我必须显示这样的日期格式“2013 年 5 月 28 日”。谁能帮我 ???
<html position="0,0,0,0" canExport="false">
<![CDATA[
<script>
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var monthname ;
if (month == 1)
monthname = "Jan";
else if (month == 2)
monthname = "Feb";
else if (month == 3)
monthname = "Mar";
else if (month == 4)
monthname = "Apr";
else if (month == 5)
monthname = "May";
else if (month == 5)
monthname = "June";
else if (month == 7)
monthname = "July";
else if (month == 8)
monthname = "Aug";
else if (month == 9)
monthname = "Sep";
else if (month == 10)
monthname = "Oct";
else if (month == 11)
monthname = "Nov";
else
monthname = "Dec";
var day = currentTime.getDate();
var dayname;
if (day == 2 ||day == 22 )
dayname = "nd";
else if (day == 3 ||day == 23 )
dayname = "rd";
else if (day == 1 ||day == 21||day == 31 )
dayname = "st";
else
dayname = "th";
var year = currentTime.getFullYear();
s = currentTime.toDateString();
alert(s);
$('[name=DateDynamic]').text(monthname+" "+day+""+dayname+" "+ year);
</script>
]]>
</html>
目前我正在遵循上述大方法。我知道应该有一些简单的方法。