如何获取某指定日期,下面提供两中添加删除指定天数、月份的方法,请参考。
对与毫秒(milliseconds)、秒(seconds)、分钟(minutes)、年份(fullYear) 处理,同样采用此方法
<fx:Script>
<![CDATA[
private function init(): void{
var _date:Date= new Date(); // 获取当前时间
_date.setDate(_date.getDate()+ 1); // 当前时间加1天
_date.date+=- 2; // 当前时间减2天
_date.setMonth(_date.month+ 1, 1); // 去得下个月1号
_date.month+= 2; // 获取2个月后的时间
df.text=_date.fullYear+ " - "+String(_date.month+ 1)+ " - "+_date.date; // 注:月份是从0开始作为1月份,因此要加1
}
]]>
</fx:Script>
<mx:DateField formatString= " YYYY-MM-DD " id= " df " left= " 100 " width= " 140 "/>
<![CDATA[
private function init(): void{
var _date:Date= new Date(); // 获取当前时间
_date.setDate(_date.getDate()+ 1); // 当前时间加1天
_date.date+=- 2; // 当前时间减2天
_date.setMonth(_date.month+ 1, 1); // 去得下个月1号
_date.month+= 2; // 获取2个月后的时间
df.text=_date.fullYear+ " - "+String(_date.month+ 1)+ " - "+_date.date; // 注:月份是从0开始作为1月份,因此要加1
}
]]>
</fx:Script>
<mx:DateField formatString= " YYYY-MM-DD " id= " df " left= " 100 " width= " 140 "/>