Store Past or Future Date and Time

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

OR

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
  • strtotime
  • date
  • setvalue

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 

Required Customizations

The highlighted elements above will need to be changed to match your survey. 

  1. First, you will want to decide if you are adding or subtracting time. If you are subtracting, change the plus sign to a minus. 
  2. 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). 
  3. To finish, change the 3 to the ID of the hidden value or question you wish to set.
Basic Standard Market Research HR Professional Full Access Reporting
Free Individual Team & Enterprise
Feature Included In