Datetime, date, time
Datetime questions allow respondents to input both date and time in a single field.
The datetime question type in XLSForms and rtSurvey enables respondents to input both date and time in a single field. This question type is useful when you need to capture a specific moment in time, including both the date and the exact time.
Basic XLSForm Specification
type | name | label |
---|---|---|
datetime | event_datetime | When did the event occur? |
For more details on the basic datetime question type, see the XLSForm specification.
Uses
Datetime questions are commonly used for:
- Recording timestamps of events or observations
- Scheduling appointments or meetings
- Logging start and end times of activities
- Capturing precise moments for time-sensitive data collection
rtSurvey Extensions
rtSurvey extends the functionality of datetime questions with various appearances and customization options:
Appearance Options
(default)
: Display the calendar and clock for selecting date and timeinline
: Display the calendar and clock as iconsinline-1line
: Display the calendar and clock for selection in a single row formatinline-onlyresult
: Display the calendar and clock as icons at the end of the line; icons disappear after selection
Color Customization
You can customize the color of the calendar and clock icons using the colors()
function:
inline colors("0099FF")
: Display icons with custom colorinline-1line-0000FF
: Display in single row format with custom colorinline-1line colors("0000FF","FFFF00")
: Display in single row format with multiple custom colorsinline-onlyresult colors("0099FF")
: Display icons that disappear after selection, with custom color
Custom Date and Time Formats
rtSurvey allows for custom date and time formats using special syntax:
inline-[%Y-%m-%d %H:%M:%S]
: Custom format example (Year-Month-Day Hour:Minute:Second)inline-[%d/%m/%Y %I:%M %p]
: Custom format example (Day/Month/Year Hour:Minute AM/PM)
Example Usage
Here’s an example of how you might use a datetime question in a survey:
type | name | label | appearance |
---|---|---|---|
datetime | incident_time | When did the incident occur? | inline-[%d/%m/%Y %I:%M %p] |
Best Practices
- Provide clear instructions on the expected date and time format.
- Consider using the
inline
appearance for a more compact display. - Use custom formats when you need specific date and time components or formatting.
- Be mindful of time zones when collecting datetime data across different regions.
Limitations
- Some appearances or custom formats may not be supported on all devices or platforms.
- Users may need guidance on inputting date and time correctly, especially with custom formats.
- Time zone differences can complicate data analysis if not properly accounted for.