Question type - Date

=Short description=

=General options=

=Display=

=Input=

=Logic=

=Other=

=Statistics=

=Dates and ExpressionScript: Advanced validation and calculation=

Limesurvey (versions 2.05+ and above) makes it fairly easy to validate dates using the date_min and date_max fields (see above). Use these whenever possible. If you need to do more advanced validation, you may be able to work (and calculate) with dates using the ExpressionScript and the function strtotime. It calculates the number of seconds from the 1st January 1970 to a given date.

Example: if you want to display in a question text the number of days that have passed since a departure date (asked in a previous question) and today, you can can use the expression {(strtotime("now")-strtotime(departure))/60/60/24}.

Please be aware that strtotime works with a lot of different formats, but with not all of them! For example, Limesurvey's default date format (MM-DD-YYYY) does NOT work with strtotime. Please set your survey to use one of the following date formats to avoid problems: YYYY-MM-DD, YYYY/MM/DD, DD.MM.YYYY, MM/DD/YYYY or DD-MM-YYYY.