我已经得到了这个基本代码:
var currentDate:Date = new Date()
var tommorow:Date = new Date()
var day3:Date = new Date()
var day4:Date = new Date()
currentDate.setDate(currentDate.getDate());
tommorow.setDate(tommorow.getDate()+1);
day3.setDate(day3.getDate()+2);
day4.setDate(day4.getDate()+3);
如果我这样做:
trace(day4);
返回:Tue Sep 1 18:16:12 GMT+1100 2015
我如何格式化这个日期以返回这个:"Tuesday 1 september 2015"
?
使用自定义格式模式的DateTimeFormatter
:
var formatter:DateTimeFormatter = new DateTimeFormatter(LocaleID.DEFAULT);
formatter.setDateTimePattern("EEEE d MMMM yyyy");
trace(formatter.format(new Date())); // ex: "Saturday 29 August 2015"
此代码有效。你可以复制这个:
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);
现在如果想显示三天后的日期,修改today
日期。
I H☻p E这有帮助。