The main question is:
How can I create a date object from a given date?
Context:
I am trying to do some calculations with a date given in the following format: DD/MM/YYYY .
What I am trying to do is to convert the given date to a date object so I could use the existing date methods (addMonths(X) / addDays(Y) ), however I could not find a method to create a date object providing the date.
The closest method I could find was Date.UTC() , which gives me the epoch representation of the given date, but I don’t know how to create a date object from it.
Current proposed step-by-step:
get date in epoch format: [[ Date.UTC(LVAR1.substr(6,4), LVAR1.substr(3,2)-1,LVAR1.substr(0,2))
convert epoch to date: ???
do necessary calculations: addMonths(-2)
convert to locale: toLocaleDateString(“pt-BR”) ]]
Thank you for your prompt response.
The expressions that you provided will give me either the date in millisecond form or in string form, which I have already managed to get with less elegant expressions, but I am looking for the date object so I could manipulate it easier with the Date methods (e.g.: addMonths(-2)).
How can we instantiate a Date object from either of these two formats?
What I needed to do was to cast the date in millis (epoch format) using a “+0” at the end and then I could manipulate it with the Date methods for calculations that I was looking for.
The final result was something like this:
[[ (LVAR1+0).addMonths(10).toLocaleDateString(“pt-BR”) ]]
where LVAR1 was the date in epoch format (time in millis from 1970).