By default, SurveyGizmo surveys record both the date and time the response was started and the date and time the response was submitted. These times are available in the time zone you specify for the application in Individual Responses and Exports.
Store Date & Time on Survey
If you wish to store date and time on each page of a survey, you can do so using the date and time merge codes.
- To set this up, add a Hidden Value Action to the page of the survey where you wish to capture the date and time. Give the Hidden Value a Name that will help you easily identify it later on.
- Below the Populate with the following field click the Select a Merge Code link.
- Within the About the Respondent tab, locate the Time & Date section where you have access to the following merge codes:
- Current Time EST
- Current Date EST
- Click the Insert link corresponding the the code that you want to use. You can add both merge codes to this same field or set up another Hidden Value action to store it as a separate field. It's totally up to you!
Once your hidden values are added the date and time will be recorded as soon as the page displays!
Note: Hidden Values are stored once and do not update if the page is hit a second time. Check out this simple script if you wish to Update Hidden Values.
Change the Format of System Date
The system date merge code [system("date")] will display the current date (in the US Eastern time) in the following format: mm/dd/yyyy. Using the format attribute you can reformat this to a different format. Learn more about formatting dates in our Advanced Merge Code Customization documentation.
[system("date"),format="Y/m/d"] will output: 2019/02/20
[system("date"),format="Y-m-d"] will output: 2019-02-20
[system("date"),format="d/m/Y"] will output: 20/02/2019
Change the Time Zone in Which the Date & Time Are Stored
The system time merge code will always store the date and time in Eastern Time (ET). If you wish to change this, we have a script that allows you to convert system time to the time zone you desire.
- To get started, you need to create a field where the converted date and time will be stored; another Hidden Value works great (in our example survey we used a Textbox Question so that we can see the conversion happen)!
- Next, create a Custom Script Action that precedes the field where you plan to store the converted value (same page or later page) and copy and paste the below script. The script is converting the existing time zone into seconds then subtracting an appropriate amount of seconds to convert what is stored in another time zone. Then it is reformatted into a date and time output that makes sense.
- You will need to make two modifications to the script:
- Change the 10800 to the value number of seconds you need to subtract to store the time zone you wish to store.
- Change the ID in the final line of the script to the ID of the field where you are storing your converted time zone. Not sure how to find the ID? Check our tutorial on How To Find Question, Page, Option ID Numbers To Use In Custom Scripts.
Time = evaluatemergecodes('[system("time")]')
TimeET = strtotime(Time)
TimeNow = TimeET - 10800 --Change the 10800 value based on the time zone you wish to store.
format = "m-d-Y h:i A"
TimeFinal = date(format, TimeNow)
setvalue(2, TimeFinal) --Change the 6 to the ID of the field where you are storing your converted time zone.
The above example converts ET to PT by subtracting 10,800 seconds (3 hours). You can manipulate this number to reflect other time zones. Below are some values for common conversions. Simply swap those out to display the desired time! Pretty nifty, right?
- ET to PT = 10800
- ET to MT = 7200
- ET to CT = 3600