Add days to date on page load


#1

I want to add days (say 15 days) to a date in input box having type text.
Text Box 1 on page load
Shows todays Date (dd/mm/yyyy) - [[Now.toISOString().substr(8,2)]]/[[Now.toISOString().substr(5,2)]]/[[Now.toISOString().substr(0,4)]]
26/08/2019

Now I want to show
Text Box 2 on page Load (dd/mm/yyyy) -
15/09/2019

Please help me to get this future date


#2

@nikhil_nine

If your local date format is dd/mm/yyyy, then can use this one below

text box 1
[[Now.toLocaleDateString()]]

text box 2
[[Now.addDays(15).toLocaleDateString()]]

you can find all the available functions here


#3

Hi Steven,

Thanks very much it worked, need just one more help… [[Now.addDays(15).toLocaleDateString()]] this shows the date in mm/dd/yyyy format. How to convert it in dd/mm/yyyy format?


#4

@nikhil_nine
so it looks it doesn’t work with your local date format, then would need to tweak a bit

text box 1
[[Now.getDate()]]/[[Now.getMonth()]]/[[Now.getFullYear()]]

text box 2
[[Now.addDays(15).getDate()]]/[[Now.addDays(15).getMonth()]]/[[Now.addDays(15).getFullYear()]]


#5

Yes !!! It worked. Thanks a lot. :slight_smile:


closed #6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.