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

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

上一篇:CSS关于div、图片居中问题


下一篇:linux shell之有类型变量