Actionscript 3 在AS3中更改日期格式
我有一个基本代码: 如果我这样做: 返回时间:2015年9月1日星期二18:16:12 GMT+1100Actionscript 3 在AS3中更改日期格式,actionscript-3,date,formatdatetime,Actionscript 3,Date,Formatdatetime,我有一个基本代码: 如果我这样做: 返回时间:2015年9月1日星期二18:16:12 GMT+1100 如何格式化此日期以返回此日期:2015年9月1日星期二?此代码有效。您可以复制以下内容: var today:Date=new Date(); var months:Array=["Jan","Feb","Mar","Apr","May","Jun","jul","Aug","Sep","Oct", "Nov","Dec"]; //you can change them to your de
如何格式化此日期以返回此日期:2015年9月1日星期二?此代码有效。您可以复制以下内容:
var today:Date=new Date();
var months:Array=["Jan","Feb","Mar","Apr","May","Jun","jul","Aug","Sep","Oct",
"Nov","Dec"];
//you can change them to your desired texts !
var days:Array=["Sat","Sun","Mon","Tue","Wed","Thu","Fri"];
var display:String=days[today.day]+" "+today.date+" "+months[today.month]+" "+today.fullYear;
trace(display);
现在,如果要显示三天后的日期,请修改今天的日期
I H☻ P这很有帮助。将与一起使用:
嗯,为什么要重新发明轮子?为什么不使用DateTimeFormatter,它不需要硬编码的英语值就可以做到这一点?是的,你的答案更好,我甚至没有听说过DateTimeFormatter。它是在Flash Player 10.1中添加的,在那之前的几年里,你的答案是唯一的选择,我自己做了很多次,我无法计数
trace(day4);
var today:Date=new Date();
var months:Array=["Jan","Feb","Mar","Apr","May","Jun","jul","Aug","Sep","Oct",
"Nov","Dec"];
//you can change them to your desired texts !
var days:Array=["Sat","Sun","Mon","Tue","Wed","Thu","Fri"];
var display:String=days[today.day]+" "+today.date+" "+months[today.month]+" "+today.fullYear;
trace(display);
var formatter:DateTimeFormatter = new DateTimeFormatter(LocaleID.DEFAULT);
formatter.setDateTimePattern("EEEE d MMMM yyyy");
trace(formatter.format(new Date())); // ex: "Saturday 29 August 2015"