How to Create Additional Intervals for the Date Time Field Time Picker

Overview

Would you like to create additional time intervals for the Date Time Field Time picker? If you would like to see and use more intervals than what the form builder provides, you can easily create more using a simple code snippet. We can show you how to use a PHP filter to create additional intervals.

Setup

By default, there are three options for the Intervals dropdown on the Time field.

By default, there are 3 interval options in the Time field

To provide an additional Intervals to the dropdown, copy this code to your site.

/**
 * Add additional intervals for the Time field Interval dropdown
 *
 * @link   https://wpforms.com/developers/how-to-create-additional-intervals-for-the-date-time-field-time-picker/
 *
 * @param  array $intervals  List of available time intervals for the Time field.
 * 
 * @return array
 */
function wpf_dev_datetime_time_intervals( $intervals ) {
      
    // Add time interval
     $intervals['5'] = esc_html__( '5 minutes', 'wpforms' );
     ksort( $intervals );
  
     return $intervals;
}
add_filter( 'wpforms_datetime_time_intervals' , 'wpf_dev_datetime_time_intervals' );

After adding the code you'll see the new option in the Interval dropdown

When the new option is selected in the form builder, users will see the new time interval while accessing the form.

The new time format is now visible on the field

Would you like to create additional formats for the Time field as well? Take a look at our article on How to Create Additional Formats for the Date Time Field Time Picker.

Filter Reference: wpforms_datetime_time_intervals