Laravel Community Tools by Tighten
Laravel Nova icon Nova Packages

Readme

Laravel Nova Time Field

This package adds a basic HTML5 time field to Laravel Nova.

Requirements

This package require laravel/nova:~4.0.

Installation

Use composer to install the package.

composer require michielfb/laravel-nova-time-field

Usage

The example below shows how to create a Time field where users can enter hours, minutes, and seconds. The time is show in the "h:i A" format (For example 11:15 PM). When no value is entered the value "n/a" is shown.

use Michielfb\Time\Time;

Time::make('Time')
    ->withSeconds()
    ->format('h:i A', 'n/a');

For documentation on how to add fields to a resource see the Laravel Nova documentation.

Format

Use the format method to customize how to date is shown to users. The format must be a PHP date format.

A default value can be passed to the format method. This determines the value shown to users if there is no value entered.

use Michielfb\Time\Time;

Time::make('Time')
    ->format('h:i A', '-');

Steps

The step attribute can be configured by using the withSteps method.

<?php 
use Michielfb\Time\Time;

Time::make('Time')->withSteps(1);

The withSeconds method sets a step of 1 which allows users to enter seconds.

<?php 
use Michielfb\Time\Time;

Time::make('Time')->withSeconds();

The withMilliseconds method sets a step of 0.001 which allows users to enter milliseconds.

<?php 
use Michielfb\Time\Time;

Time::make('Time')->withMilliseconds();

Screenshots

Reviews

By Mike on April 14, 2020

Works like a charm. Thank you.

Back to Top
Added 6 years ago
Last updated 1 Year Ago
Version 2.1.0
Nova Version ^4.0|^5.0
Composer
michielfb/laravel-nova-time-field
GitHub stars 21
Packagist downloads 398,586

Favorites

3 users favorited

Rating

5.00
(out of 5)
★★★★★
★★★★
★★★
★★
4 ratings

Author

Brought to you by Tighten

Issues/Feature Requests Stats Package Ideas