JS将日期转换为英文格式输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<script language="javascript">
    var dt = new Date();
    var m=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Spt","Oct","Nov","Dec");
    var w=new Array("Monday","Tuseday","Wednesday","Thursday","Friday","Saturday","Sunday");
    var d=new Array("st","nd","rd","th");
    mn=dt.getMonth();
    wn=dt.getDay();
    dn=dt.getDate();
    var dns;
    if(((dn%10)<1) ||((dn%10)>3)){
    dns=d[3];
    }
    else
    {
    dns=d[(dn%10)-1];
    if((dn==11)||(dn==12)){
    dns=d[3];
    }
    }
    document.write(m[mn]+" "+dn+dns+" " +w[wn-1]+" "+dt.getFullYear());
</script> 

  

 

输出格式:Feb 12th Wednesday 2014

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。