Simple time field

This project is not covered by Drupal’s security advisory policy.

The Simple Time Field module provides a lightweight, dedicated time-of-day field type for any fieldable Drupal entity. Unlike Drupal core's date field, which bundles dates and timezones, this module focuses exclusively on the time component. It stores values in a standardized format (HH:MM or HH:MM:SS) and offers a wide range of configurable display options, making it the perfect solution for business hours, event schedules, and appointment slots.

Features

  • Pure Time Storage: Focuses strictly on time (00:00 to 23:59) without the overhead of date components or complex timezone conversions.
  • Native Browser Integration: Utilizes HTML5 time input elements for a seamless user experience, including support for min, max, and step attributes.
  • Flexible Granularity: Configure time intervals ranging from 1-second precision to 1-hour slots to match your specific use case.
  • Powerful Formatting: Ships with four formatters, including a highly configurable "Time (configurable format)" option that supports custom PHP date strings and display-only timezone shifting.
  • Feeds Integration: Automatically registers a Feeds target to normalize human-readable strings like "2pm" or "14:30" during imports.
  • Views Compatibility: Stored as a varchar string, allowing for reliable alphabetical sorting and filtering within Drupal Views.

Installation

The recommended installation method is via Composer to ensure all internal dependencies are correctly mapped.

composer require drupal/simple_time_field

Enable the module using Drush:

drush en simple_time_field
drush cr

Configuration Workflow

Setting up a time field is integrated directly into the standard Drupal Field UI:

  1. Add Field: Navigate to Structure » [Entity Type] » Manage fields and add a new field of type "Time".
  2. Storage Settings: Choose whether to Include seconds in the data storage.
  3. Manage Form Display: Click the gear icon on the field to set Minimum/Maximum time restrictions and the Time interval (step).
  4. Manage Display: Choose your preferred formatter (e.g., 12-hour AM/PM or 24-hour) and optional timezone offsets for output.

Feeds Integration

When the Feeds module is enabled, Simple Time Field provides a specialized mapper. It is designed to be "smart"—it attempts to parse arbitrary strings using strtotime(). This means you can import data from messy CSVs containing "2:30 PM" and have it correctly stored as "14:30" without manual pre-processing.

Additional Requirements

This module requires Drupal 9, 10, or 11. It has no mandatory external library dependencies. For import functionality, the Feeds module is recommended but optional.

Similar projects

  • Date (For full date/time stamps with timezone support)
  • Office Hours (Specifically tailored for weekly business opening slots)
  • Duration Field (For storing lengths of time rather than a specific time of day)

Supporting this Module

If you encounter bugs, require assistance with time pickers in specific browsers, or have feature suggestions, please use the official issue queue. We particularly welcome feedback on expanding the Feeds normalization logic or adding new preset formatters.

Supporting organizations: 
Development and Maintenance Support

Project information

Releases