如何在flex中设置添加1天的日期?
答案 0 :(得分:5)
Flex不是基于ECMA(基本上是javascript),如果是这样,尝试只添加86400000毫秒到日期对象?类似的东西:
var mili = 1000;
var secs = 60;
var mins = 60;
var hours = 24;
var day = hours * mins * secs * mili;
var tomorrow = new Date();
var tomorrow.setTime(tomorrow.getTime() + day);
答案 1 :(得分:3)
var now:Date = Date();
var currentDate = now.date;
var currentMonth = now.month;
var currentYear = now.fullYear;
var tomorrow:Date = new Date(currentYear, currentMonth, currentDate + 1);
var lastWeek:Date = new Date(currentYear, currentMonth, currentDate - 7);
var lastMonth:Date = new Date(currentYear, currentMonth-1, currentDate);
等
答案 2 :(得分:3)
使用:
var date:Date = new Date();
date.setDate(date.getDate() + 1);
考虑到夏季时间的变化,天数为23小时或25小时。
干杯
答案 3 :(得分:2)
我从this blog post获取了这个辅助函数,但它只是一个片段。
用法很简单:
dateAdd("date", +2); //now plus 2 days
然后
static public function dateAdd(datepart:String = "", number:Number = 0, date:Date = null):Date
{
if (date == null) {
date = new Date();
}
var returnDate:Date = new Date(date.time);;
switch (datepart.toLowerCase()) {
case "fullyear":
case "month":
case "date":
case "hours":
case "minutes":
case "seconds":
case "milliseconds":
returnDate[datepart] += number;
break;
default:
/* Unknown date part, do nothing. */
break;
}
return returnDate;
}
答案 4 :(得分:1)
或者如果你正在使用一个奇特的解决方案,你可以使用库Flex Date Utils http://flexdateutils.riaforge.org/,它有很多有用的操作
最好的