nonini / format
Arbitrary collection of Format helpers
dev-main
2026-11-12 08:32 UTC
Requires
- php: >=8.1
- ext-intl: *
Requires (Dev)
- phpstan/phpstan: ^1.10 || ^2
- phpunit/phpunit: ^10.3 || ^13
- squizlabs/php_codesniffer: ^3.7 || ^4
- symplify/easy-coding-standard: ^12.0.8 || ^13
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-11-12 23:04:19 UTC
README
A small PHP library for locale- and timezone-aware date/time formatting, built on top of IntlDateFormatter.
It provides two classes:
LocalTimeFormat– formats times (12h vs. 24h depending on locale, AM/PM foren_US).LocalDateFormat– formats full dates.
Usage
Formatting times and dates
$time = new LocalTimeFormat(); $time->setLocale('en_US'); $time->setTimezone(new DateTimeZone('Europe/Berlin')); echo $time->getTime(new DateTime('2026-11-11 21:50:12')); // "9:50:12 PM" echo $time->getShortTime(new DateTime('2026-11-11 21:50:12')); // "9:50 PM" echo $time->getMonthName(new DateTime('2026-11-11')); // "November" $date = new LocalDateFormat(); $date->setLocale('de_DE'); echo $date->getFullDay(new DateTime('2026-11-11')); // "Mittwoch, 11. November 2026"