Search by

nonini / format

nonini

Arbitrary collection of Format helpers

Package info

github.com/nonini/format

pkg:composer/nonini/format

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-11-12 08:32 UTC

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 for en_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"