Download the PHP package builtnoble/duration-fieldtype without Composer
On this page you can find all versions of the php package builtnoble/duration-fieldtype. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download builtnoble/duration-fieldtype
More information about builtnoble/duration-fieldtype
Files in builtnoble/duration-fieldtype
Package duration-fieldtype
Short Description A Statamic fieldtype for storing and displaying time durations as millisecond-precision integers, entered via a masked hh:mm input.
License MIT
Informations about the package duration-fieldtype
Duration Fieldtype
A Statamic fieldtype for storing and displaying time durations. Values are saved as integers in milliseconds, entered via a masked
hh:mminput in the Control Panel, and output in Antlers templates as either plainhh:mmor an optional human-readable string.
Features
- Millisecond integer storage — values are saved as raw integers (e.g.
5400000for 1 hour 30 minutes), keeping arithmetic and sorting predictable - Masked
hh:mminput — the Control Panel field renders a masked input that automatically formats digits as hours and minutes, capped at99:59by default - Configurable max hours — cap the field below 99 hours (e.g.
8for a workday tracker) via the field's "Max Hours" setting; minutes always range00–59 - Keyboard stepping — pressing
↑or↓while the field is focused increments or decrements whichever single digit the cursor sits immediately after - Paste support — pasting any text extracts its digits and replaces the field's value, clamped to the field's bounds
- Truncation to minute — partial minutes are discarded on load; sub-minute precision is not stored or displayed
- Antlers ready — augmented values default to plain
hh:mm(matching the Control Panel display) unless all four unit labels are configured, in which case they become a human-readable string (e.g.01 hr 30 mins, or1 hr 30 minswith leading zeros stripped) with the minutes segment omitted entirely when zero - Localizable labels — optionally configure
hr/hrs/min/mins-style labels per field, so a site can translate them without the addon needing to bundle every language - Null-safe — null values display as
00:00in the CP and00 minsin templates
Requirements
- PHP 8.3+
- Statamic 6.0+
How to Install
Install the addon via Composer:
Then add the fieldtype to any blueprint in the Control Panel or directly in resources/blueprints/.
Documentation
See DOCUMENTATION.md for configuration options and a full explanation of how the fieldtype works internally.
Development
See CONTRIBUTING.md for the full development setup and workflow.