Flex: add 1 day to a specific date

How can I set the date by adding 1 day to flex?

+4
source share
5 answers

Not ECMA-based Flex (mostly javascript), if so, try adding 86400000 milliseconds to the date object? Sort of:

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); 
+5
source

tommorow date arithmetic proposed by @Treby can be used this way using the Date constructor (year, month, day):

 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); 

and etc.

+3
source

Using:

 var date:Date = new Date(); date.setDate(date.getDate() + 1); 

Because this applies to summer replacement days, when the days are 23 hours or 25 hours.

Greetings

+3
source

I took this helper function from this blog post , but this is just a snippet.

The use is simple:

  dateAdd("date", +2); //now plus 2 days 

then

 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; } 
+2
source

or if you are after an unusual solution, you can use the Flex Date Utils library http://flexdateutils.riaforge.org/ , which has many useful operations

it's better

+1
source

Source: https://habr.com/ru/post/1305195/


All Articles