How do I add days to a date object?
# suitescript
b
How do I add days to a date object?
j
You can do that with vanilla js.
Copy code
new Date(Date.now() + days * 24*60*60*1000);
Or you can load an AMD module like moment.js if you want to be fancy
b
I must be missing something, that gave me the same date
j
you might want to log out the typeof "rDate" and "tranTime". They might be strings, and to do the calculation right it may need to be more like
Copy code
var eta = new Date(new Date(rDate) + parseInt(tranTime) * 24*60*60*1000);
b
I created the custom fields, rDate is a Date and tranTime is an integer
j
Yeah, but when you use a get operation on them, they might come back as strings. Especially sublist fields.
b
I see, ok thank you I will do that
solution