how can i set a date adding 1 day in flex??
+1
A:
Isn't Flex based on ECMA (basically javascript), if so, try just adding 86400000 milliseconds to the date object? Something like:
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);
Anthony
2010-03-26 07:00:01
nice.. this works.. but this also worktommorow.date = tommorow.date +1it automatically change the year and month if it reaches the end of each month
Treby
2010-03-26 07:16:35
That is nice. Would adding 24 hours to a date not do that?
Anthony
2010-03-26 07:20:39
yah this works.. that y i checked your answer..
Treby
2010-03-29 01:45:39
+1
A:
tommorow date arithmetic suggested by @Treby can be uses this way by using Date(year, month, day) constructor :
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);
etc.
Nishu
2010-03-26 08:13:05
A:
or if you are after a fancy solution you can use the library Flex Date Utils http://flexdateutils.riaforge.org/, which has a lot of useful operations
best
Arian Pasquali
2010-03-26 17:24:24
+1
A:
I took this helper function from some blog post (I don't remeber the source) but is just a snippet.
the usage is simple:
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;
}
Felipe
2010-03-26 18:05:07
A:
Use:
var date:Date = new Date();
date.setDate(date.getDate() + 1);
As this considers the summer timechange days, when days have 23h or 25h.
Cheers
David Santa Olalla
2010-10-19 11:10:55