时间转换成英文显示

    ENdateTranslation(date){
            var dt = new Date(date);
            var m=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Spt","Oct","Nov","Dec");
            var w=new Array("Mon","Tue","Wed","Thu","Fri","Sat","Sun");
            var d=new Array("st","nd","rd","th");
            let mn=dt.getMonth();
            let wn=dt.getDay();
            let 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];
                }
            }
            return (w[wn-1] +" , " +" "+dn + m[mn]);
     },

var scheduledDateTime="2019-12-31 09:10:00"
ENdateTranslation(scheduledDateTime)

//  Tue , 31Dec 

!资料来源于网络,如有侵权,请联系!

你可能感兴趣的:(JavaScript)