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:
composer require builtnoble/duration-fieldtype
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
composer test # Pest (PHP)composer test:feature # Pest, feature-grouped onlycomposer lint # Pint, check onlycomposer analyse # PHPStancomposer check # lint + analyse + test, all at once
See CONTRIBUTING.md for the full development setup and workflow.