In flex, I am trying to do date deduction and addition, but couldn’t find a way to do it.
e.g.:
public var dateNow:Date=new Date();
How can I get the Date 3 months earlier than dateNow?
Thanks!!!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the Date constructor for this. The first argument to Date’s constructor takes either a year or a timestamp. You can use the
Date.timeproperty to get the timestamp from a date object. Once you have the timestamp you can add/subtract some number of seconds from it, and then pass it tonew Date(timestamp)and you get a brand new date which represents the new timestamp.Edit;
As a commenter pointed out, time manipulation may not be the best way to go. But you can still use the Date constructor as follows:
The Date constructor is smart enough to deal with negative values, or values greater than 11.