Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
105
rated 0 times [  109] [ 4]  / answers: 1 / hits: 43002  / 10 Years ago, thu, july 17, 2014, 12:00:00

We are using AngularJS to set filters.
Basically we have a start date and end date and frequency. When the frequency is set to week, we simply want to add 1 week to the start date, when the frequency is set to daily, we want to add 1 day to the start date.



Basically something like :-



var date = new date();

date.addDays(2);
date.addMonths(2);
date.addYears(2);

More From » angularjs

 Answers
54

I would consider using moment.js for all of your JS date related needs then you can do:



var date = moment();
date.add(2, 'days');
date.add(2, 'months');
date.add(2, 'years');

// or all of the above with:
date.add({years: 2, months: 2, days: 2});


And if you need a regular JS date object at the end, check out this post


[#70167] Tuesday, July 15, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
estefanib

Total Points: 508
Total Questions: 104
Total Answers: 83

Location: Lebanon
Member since Sun, Aug 2, 2020
4 Years ago
;