My simple problem is I can not add 30 days to a date:
For a button click I want to write a date in a field in a collection (today date + 30days).
I do some calc with dates working fine but this one is not working:
export function button10_click(event, $w) { let datenow = Date(); let days = (30*24*60*60*1000); let expiration = datenow+days; $w("#dynamicDataset").setFieldValue("expirationdate", expiration); let originalDate111 = $w("#text103").text; let newDate111 = originalDate111.split(' ').splice(0, 4).join(' '); $w('#text103').text = newDate111;
This way the date is always equal the current date not the current date+30 days.
Any advice?
thanks!
Imre
Thx Ysrael,
yep I missed it.
Can you check my other issue with dates comparing in a query?
https://www.wix.com/code/home/forum/questions-answers/wixdata-query-ge-gt-l-lt-not-working-for-dates
Thx in advance!
Imre
Hi,
You don't have r defined. I suspect you mean:
let date = new Date(); date.setDate(date.getDate() + 30);
And the working code is - if anybody needs:
(adding 30 days to a date (today))
var date = new Date(); date.setDate(r.getDate() + 30);