Want to use a future or past date dynamically in a survey? This script adds or subtracts time to/from the current date.
Check it out in an example survey
Add a survey with this setup to your account!
This script uses the following features and functions:
- Hidden Value to store date for later use
Copy and paste the script in a Custom Script Action that precedes the Hidden Value you wish to set.
Once this is set up you'll be able to use the merge code for that hidden action later on in your survey!
format = "Y-m-d" now = strtotime(date(format)) + 172800 twodays = date('Y-m-d',now) setvalue(3,twodays) -- 3 is the ID of the Hidden Value
The highlighted elements above will need to be changed to match your survey.
- First, you will want to decide if you are adding or subtracting time. If you are subtracting, change the plus sign to a minus.
- Next decide how much time you'd like to add or subtract. Calculate that time into seconds and put that in place of 172800 (2 days in seconds).
- To finish, change the 3 to the ID of the hidden value or question you wish to set.