Skip to main content

Kinesis Support

All the topics, resources needed for Kinesis.


FocusVision Knowledge Base

Date and Time Examples

1:  Translating Date questions

Our Date question type provides support for localizing its content to cater for different languages. Each localization is contained within its own file with the language code appended to the name, e.g., jquery.ui.datepicker-fr.js for French.

The $.datepicker.regional attribute holds an array of localizations, indexed by language code, with "" referring to the default (English). Each entry is an object with the following attributes: closeText, prevText, nextText, currentText, monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, weekHeader, dateFormat, firstDay, isRTL, showMonthAfterYear, and yearSuffix.

You can restore the default localizations with: $.datepicker.setDefaults( $.datepicker.regional[ "" ] );

And can then override an individual datepicker for a specific locale: $( selector ).datepicker( $.datepicker.regional[ "fr" ] );

Below you will find the paths for each supported language. You can include these in the surrounding HTML for your Date question. See example below:

<script type="text/javascript" src="">

       $("#Q6").datepicker("option", $.datepicker.regional["es"]);

Available languages and landcodes are listed below (make sure to use full URL path as shown in example above):


2:  Calculating Age From Date of Birth

Recording a respondents age is very simple but the logic depends on the question type being used to record the date of birth. The following code is the basic template based on using a separate open end for the month, day, and year. The first 3 lines will need to be updated to reflect the question labels within your particular survey.


$USER_month = $Qmonth;
$USER_day = $Qday;
$USER_year = $Qyear;

$USER_year_diff = date("Y") - $USER_year;
$USER_month_diff = date("m") - $USER_month;
$USER_day_diff = date("d") - $USER_day;

if ($USER_month_diff < 0) $USER_year_diff--;
elseif (($USER_month_diff==0) && ($USER_day_diff < 0)) $USER_year_diff--;
return $USER_year_diff;

2.1:  From Date Question

When using the Kinesis Date question type, the first 3 lines will need to be altered. You will need to reference the date question label and field order in brackets (starting from 0). The first 3 lines would be written like this:

$USER_year = $Qdob[0];
$USER_month = $Qdob[1];
$USER_day = $Qdob[2];

Please note that, regardless of the date format, the year gets stored in the first field [0] of the date question, the month in the second [1] and the day in the third [2].

2.2:  From Pulldown Question

When using a question such as a pulldown, these first 3 lines would need to be altered because pulldowns record the choice id and not the choice text. So the month and day part would not need to change. For example, "January" as the first month choice would already correspond to the value of "1", and the same for day choice of 20 would match the value "20". Most often the year will be recorded from a range of years, such as 1900-2000. In this case the first option choice of 1900 would have a value of 1, and would throw off the code. So we would need to add a number to the value that will get the same number as the choice text. So 1+1899 = 1900, 2+1899 = 1901 and so on.

$USER_month = $Qmonth;
$USER_day = $Qday;
$USER_year = $Qyear+1899;

3:  Return Difference Between Dates

This example will calculate the difference between two date questions. Create both date questions - Qstart and Qend. Next, create a number question with the logic below for the default answer condition:


$USER_days = (strtotime("$Qend[0]-$Qend[1]-$Qend[2]") - strtotime("$Qstart[0]-$Qstart[1]-$Qstart[2]")) / (86400);
return $USER_days;

The above code subtracts start time from end time, then divides by 86400 (one day in seconds). Dates are always stored in data with format YYYY-MM-DD, regardless of input mask.

4:  Disabling the DatePicker popup

Use the following javascript example to disable the default popup calendar for  Date Questions. Note this script call must be on the same screen as the date question to work, after the date question. In the syntax below, the datapoint for your date question is represented by QDOB.

    <script type="text/Javascript">
  • Was this article helpful?