Actions

Translations

Question type - Date/27/en: Difference between revisions

From LimeSurvey Manual

(Importing a new version from external source)
 
(Importing a new version from external source)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
Limesurvey versions 2.05+ and above make 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 fancy stuff, you may be able to work (and calculate) with dates using Expression Manager and the function strtotime(){{NewIn|2.0|b=130515}}. 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}.
Limesurvey (versions 2.05+ and above) makes it fairly easy to validate dates using the [[Question type - Date#Minimum date (date_min)|date_min]] and [[Question type - Date#Maximum date (date_max)|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 - Presentation|ExpressionScript]] and the function strtotime(). It calculates the number of seconds from the 1st January 1970 to a given date.
Please be aware that strtotime() works with a lot of different but not ALL date formats. 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, DD-MM-YYYY.

Latest revision as of 16:55, 19 May 2020

Message definition (Question type - Date)
Limesurvey (versions 2.05+ and above) makes it fairly easy to validate dates using the [[Question type - Date#Minimum date (date_min)|date_min]] and [[Question type - Date#Maximum date (date_max)|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 - Presentation|ExpressionScript]] and the function strtotime(). It calculates the number of seconds from the 1st January 1970 to a given date.

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.