After callback from pay service (when user has paid the new subscription) I want to save his new subscription to his/her account in DB. Using Mongoose I want to save new subscription start and end Dates in the user account like this:
const start = Date.now();
const end = ?
const subscription = {
start: start,
end: end,
}
account.subscriptions.push(subscription);
await account.save();
I can get the subscription start date using const start = Date.now();
But how can I calculate the end date of subscription if this is a 20 days package?
I should add 20 days to start date how can I do this?