Download the PHP package harvirsidhu/filament-timepicker without Composer

On this page you can find all versions of the php package harvirsidhu/filament-timepicker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filament-timepicker

Filament Smart Time Picker

A type-ahead time field for Filament. Your users just type — 3p, 330, 3:30 PM, 1530 — and a filterable, keyboard-navigable dropdown suggests times at whatever interval you pick. It looks and behaves like a native Filament field, but it's far more forgiving for the people filling in your forms all day.

Requirements: PHP 8.2+ · Filament v4 or v5


Contents


What you get


Quick start

1. Install the package

2. Publish the assets (copies the lazy-loaded JavaScript into /public)

3. Use it in a form

That's it. The field stores a plain H:i string like "15:30", so it drops straight into a time column with no casting or accessors.

Using a custom Filament theme? One extra step: add the package's views to your theme so Tailwind compiles the dropdown styles. In your theme's resources/css/filament/<panel>/theme.css:

Then rebuild: npm run build. (Skip this if you use Filament's default styling.)


How input parsing works

The whole point of this field is that people can type a time however they think of it, and it still ends up stored cleanly. Here's the mapping:

The user types Stored as Displayed as
9 09:00 9:00 am
3p 15:00 3:00 pm
330 03:30 3:30 am
1530 15:30 3:30 pm
3:30 PM 15:30 3:30 pm
9.30 / 9h30 09:30 9:30 am
nonsense rejected

Separators are flexible. In the hh:mm part you can use a colon, a dot, or an h — so 9:30, 9.30 (common in the UK and Malaysia), and 9h30 (French) all parse to the same value.

Bad input never reaches your database. Parsing happens twice: instantly in JavaScript for a snappy feel, and authoritatively in PHP on the server. The server always has the final say, so a saved value is either a clean H:i (or H:i:s) string, or null.


Recipes

Set a default value

Use Filament's standard ->default(). It accepts the same forgiving formats and normalizes them for you:

->default('15:30'), ->default('330'), and ->default('3:30 PM') all work. For a dynamic default, pass a closure:

Filament only applies default() when creating a record, not when editing one.

Restrict to a window (e.g. opening hours)

minTime / maxTime accept a string, a Carbon instance, or a closure — so a bound can depend on another field:

Start & end times, with live duration labels

Point an "end time" at its "start time" with durationFrom(). The dropdown then only offers times after the start, and labels each option with how long the gap would be:

Each option is labelled with the gap from the start time: up to an hour in friendly words ((30 mins), (1 hour)), and past an hour in a compact form ((1h 30m), (2h)) so longer gaps stay short. Pass the sibling field's name ('start_time'), not its full path — durationFrom() resolves it for you, even inside repeaters and nested groups.

Auto-fill the end time from a default duration

Pair durationFrom() with defaultDuration() so picking (or changing) the start time fills the end time automatically. The user can still override it afterwards:

Choose any default — ->defaultDuration(10) lands on 12:10 pm. It fires only when the start time changes, so an existing end time on an edit form is left untouched, and the value is capped at maxTime() (or the end of the day) if the sum would overflow.

It keeps the gap. Whenever the end time differs from the default — set by the user, or by your own logic (an afterStateUpdated, a $set) — that gap is preserved on later start changes instead of snapping back to the default. Pick 12:00 pm → end fills to 12:30 pm; change the end to 1:00 pm (a 1-hour gap); move the start to 1:30 pm and the end follows to 2:30 pm, keeping the hour. The gap is read live (and runs client-side — no server roundtrip), and is seeded from an existing start/end pair on an edit form.

This is what lets a per-category duration coexist with the picker: set end_time from your own field (e.g. an appointment type's minutes) via afterStateUpdated, and the picker preserves that gap when the user nudges the start — without a Livewire roundtrip each time.

Show seconds

Change how the time is displayed

The visible text uses PHP date() tokens. The default is g:i a (e.g. 3:30 pm):

This only changes what's shown — the stored value is always canonical H:i/H:i:s.

Lock input to the grid (strict mode)

By default the field is forgiving: a user can type any valid time (e.g. 12:01) even if it isn't one of the suggested slots. Call strict() to confine values to the interval grid:

With strict on, typing an off-grid time snaps the box back to the last valid value as you go, and any off-grid value that bypasses the browser (a paste, a programmatic default, a CSV import) fails server-side validation with a clear message rather than being silently dropped.


API reference

Method Default Description
interval(int\|Closure) 15 Minutes between dropdown suggestions.
minTime(string\|Carbon\|Closure\|null) null Earliest selectable time (inclusive).
maxTime(string\|Carbon\|Closure\|null) null Latest selectable time (inclusive).
durationFrom(string\|Closure\|null) null Sibling field name; floors options after it and adds duration labels.
defaultDuration(int\|Closure\|null) null Minutes; auto-fills this field when the durationFrom field changes.
displayFormat(string\|Closure) 'g:i a' How the value is shown, in PHP date() tokens.
seconds(bool\|Closure) false Store/display seconds (H:i:s).
strict(bool\|Closure) false Confine values to the grid; off-grid times fail validation.
native(bool\|Closure) No-op. Accepted for drop-in parity with Filament's TimePicker.
timezone(string\|Closure\|null) No-op. Times are wall-clock and never shift.

All the usual Filament Field methods (->label(), ->required(), ->disabled(), ->prefixIcon(), ->placeholder(), ->live(), …) work as you'd expect.

Parsing time strings anywhere

The parser is a plain, dependency-free class you can reuse outside the field — in validation, imports, API endpoints, anywhere:


Migrating from Filament's TimePicker

It's a drop-in replacement. Swap the import and the class name — your existing call chain keeps working, because native() and timezone() are accepted as harmless no-ops:


Keyboard shortcuts

The field follows the ARIA combobox/listbox pattern, so it's fully operable from the keyboard and announced by screen readers.

Key Action
Type Filter the suggestions live
↑ / ↓ Move through the suggestions
Enter Select the highlighted suggestion
Tab Select the highlighted suggestion & move on
Esc Close the dropdown

Troubleshooting

The dropdown shows up unstyled (no colours, wrong layout). You're using a custom Filament theme and haven't told Tailwind about the package's views. Add the @source line from Quick start, then rebuild your theme with npm run build.

Nothing happens when I focus the field / the JS doesn't load. Run php artisan filament:assets and reload. This publishes (and re-publishes) the lazy-loaded component into /public. Re-run it any time the package updates.

A typed time gets blanked out on save. The value didn't parse. Check the parsing table — anything unrecognised normalizes to null. If you're in strict() mode, an off-grid time is rejected by design (with a validation message when it bypasses the browser).

durationFrom() labels or defaultDuration() auto-fill aren't updating. Make the source field ->live() so its value propagates as it changes.


Translations

Every user-facing string — the "no matching time" hint, the strict-mode validation message, and the durationFrom duration words ("hour", "mins", "h", "m") — lives under the harvirsidhu-filament-timepicker namespace. Publish them to translate or override:

Then edit lang/vendor/filament-timepicker/<locale>/time-picker.php.


How it works under the hood

Curious or extending it? The design choices that matter:


Contributing & development

The compiled resources/js/dist/ file is committed — consumers don't build it. After changing the JS, rebuild, then in any consuming app re-run php artisan filament:assets to re-publish.

If you change a parsing rule, change it in both src/Support/TimeParser.php (PHP, authoritative) and resources/js/components/smart-time-picker.js (JS), and update both test suites — they're meant to stay in lockstep.


Credits

License

The MIT License (MIT). See LICENSE.md.


All versions of filament-timepicker with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
filament/filament Version ^4.0|^5.0
spatie/laravel-package-tools Version ^1.15.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package harvirsidhu/filament-timepicker contains the following files

Loading the files please wait ...