- What is armincms/duration used for in Laravel?
- armincms/duration is a Laravel package for working with time durations. It lets you parse interval values, format them for human-readable output, compare durations, and perform duration math through an expressive PHP API. It is useful anywhere your application needs to present or manipulate time spans rather than absolute dates.
- How do I install armincms/duration with Composer?
- Install the package with Composer by running composer require armincms/duration. If the package registers a Laravel service provider, Laravel's package discovery should wire it up automatically; otherwise follow any publish or registration steps in the README. Commit your composer.lock change after installation so deployments are reproducible.
- Which Laravel and PHP versions does armincms/duration support?
- The supported Laravel and PHP versions are defined in the package's composer.json, so check that file or the README before adding it to an existing application. Maintained Laravel packages commonly target a modern PHP 8+ and Laravel 8+ baseline, but you should confirm the exact constraints for the release you install. If you are upgrading a legacy application, run composer why-not to catch version conflicts early.
- How do I parse a duration string like 1h 30m in Laravel?
- Use the package's duration parser to turn interval strings such as 1h 30m or ISO 8601-style values into a duration object. Once parsed, that object can be formatted, compared, or converted into other units. The README documents the exact constructor or factory method name for your installed version.
- How do I format a duration as human-readable text?
- Formatting is a core feature of armincms/duration: it converts a duration value into human-readable output for UI messages, reports, or logs. Depending on the API version, you can usually control which units appear and whether the output is compact or verbose. Check the README for the available format tokens and options.
- Can I convert durations to seconds, minutes, or hours?
- Yes, the package is designed for converting interval values between units, so you can express a duration in seconds, minutes, hours, or other supported measures. Conversion methods also make duration math easier without manual arithmetic. Confirm the exact method names and rounding behavior in the README for your release.
- How do I compare two durations with armincms/duration?
- Duration comparisons are one of the package's stated use cases. You can compare two duration values to determine which is longer or to check equality using the package's comparison API. For exact method signatures and edge cases such as negative durations, consult the README.
- Can I use armincms/duration outside Laravel or in unit tests?
- Because this is a Laravel package, it may rely on Laravel helpers or container features, but duration math itself is often framework-agnostic. In tests you can typically instantiate duration objects directly without booting the full application. Verify any Laravel-specific dependencies in composer.json and look for a documented framework-free usage path if you need one.
- Is armincms/duration safe to use in production?
- The package is small in scope, so the main production concerns are maintenance cadence, documentation quality, and undocumented API changes. Before committing, review the repository's commit history, open issues, and release notes. Pin a specific version in composer.json and read the changelog before upgrading.
- What are alternatives to armincms/duration for duration handling in PHP?
- Common alternatives include PHP's native DateInterval and DateTime APIs, CarbonInterval from nesbot/carbon (which most Laravel applications already have), and standalone libraries such as php-duration. Choose armincms/duration if you want its expressive Laravel-friendly API; otherwise CarbonInterval often covers the same parsing, formatting, and comparison needs.