logo
v2.7.6

Timepicker

Display a timepicker. There are two styles to choose from. Popup and inline. The default is popup.

                
                    <x-bladewind::timepicker  />
                
            

HH
MM
--
                
                    <x-bladewind::timepicker style="inline"  />
                
            

Time Formats

By default the timepicker displays time in the 12 hour format. This format has hours from 1 to 12 and an AM/PM suffix. To change this to a 24 hour format, set format="24". The 24 hour time format gets rid of AM/PM suffix and displays the hours from 01 to 00. Note how the hours in 24 hour format are double digits.

                
                    <x-bladewind::timepicker format="24"  />
                
            

HH
MM
                
                    <x-bladewind::timepicker style="inline" format="24"  />
                
            

Required Fields

An asterisk is appended to the placeholder text when required="true".

   
                
                    <x-bladewind::timepicker required="true"  />
                
            
                
                    <x-bladewind::timepicker label="HH:MM" required="true"  />
                
            

HH
MM
--
                
                    <x-bladewind::timepicker style="inline" required="true"  />
                
            

Default Values

There are times you will want the timepicker to be prepopulated with a default time. This is useful when in edit mode. To achieve this, set the selected attribute to the time you will like to display. The format of the time you set will depend on the format defined on the timepicker.

                
                    <x-bladewind::timepicker selected_value="3:25PM"  />
                
            
                
                    <x-bladewind::timepicker selected_value="03:25" format="24" />
                
            

HH
MM
--
HH
MM
HH
MM
                
                    <x-bladewind::timepicker style="inline" selected_value="3:25PM"  />
                
            
                
                    <x-bladewind::timepicker style="inline" format="24" selected_value="03:25"  />
                
            

<x-bladewind::timepicker
    required="true"
    style="inline"
    format="24"
    selected_value="03:25"  />

Form Values

Typically in a form, you should specify a name for your timepicker component. A default random name is generated if no name is specified. Let's assume in our form the timepicker is named event_time. An input is created with the name specified. In this case event_time.

When your form is submitted, you will be able to retrieve the time as shown below.

        
            // if format="12" (default)
            $request->event_time; // outputs 1:25PM

            // if format="24"
            $request->event_time; // outputs 01:25
        
    

 

Full List Of Attributes

The table below shows a comprehensive list of all the attributes available for the timepicker component.

IMPORTANT: Projects running Laravel 8 please read this

Option Default Available Values
name bw-timepicker This name can be accessed when the input is submitted in the form.
format 12 The format time should be displayed in. 12 24
selected_value blank In edit mode, the value passed will be set as the default time.
hour_label HH Label to display for the hour dropdown.
minute_label MM Label to display for the minute dropdown.
format_label -- This applies only if using the inline timepicker. Label to display for the time format dropdown.
placeholder HH:MM This applies only if using the popup style. Placeholder to display in the input field.
label blank This applies only if using the popup style. Label to display in the input field. The label behaves just like in the BladewindUI Input component
style popup Determines how to display the timepicker.
popup inline
required false Determines if the placeholder text should have an asterisk appended to it or not. Value needs to be set as a string not boolean.
true false

 

Timepicker with all attributes defined


<x-bladewind.timepicker
    name="start_time"
    format="24"
    required="false"
    hour_label="hh"
    minute_label="mm"
    format_label="AM/PM"
    placeholder="Start Time"
    label="Start Time"
    style="inline"
    selected_value="12:35AM" />

 

The source file for this component is available in resources > views > components > bladewind > timepicker.blade.php

The source language (translation) files for this component are available in lang/[lang]/timepicker.php