I have a date in this format – 20230926 (yyyymmdd).
whatever date I get at runtime I want to have dates till next 120 days in an array. For example If I get date 20230926. Then my final array should contain date from today till next 120 days. Means final array will have 120 records.
finalArray = [26-09-2023,27-09-2023,28-09-2023.
.etc till next 120 days]
. How can I do that?
2
Answers
You can use a for-loop to iterate through a date object. For each step, increment the date by 1.
You can use
getDate()
to get the current date and increment days and set usingsetDate()
. You have to do it upto 120 times to reach your limit.To deal with Local time,
For UTC operations, Use