phdevutils / dates
Philippine date utilities — business-day arithmetic (PH holiday-aware) and Filipino (Tagalog) date formatting. Companion to phdevutils/core.
Requires
- php: >=8.2
- phdevutils/core: ^0.3.1
Requires (Dev)
- phpunit/phpunit: ^10.0
README
Philippine date utilities for PHP + JS — business-day arithmetic (PH holiday-aware) and Filipino (Tagalog) date formatting. Companion to phdevutils/core (uses its bundled 2025–2026 PH holiday calendar).
composer require phdevutils/dates
Why
Every PH HR / leave / cutoff / accounting / SLA app hits the same problem: "what date is N business days from today, skipping weekends and the PH holiday calendar?" — and the late-December gauntlet (Christmas Eve, Christmas, Rizal Day, New Year's Eve all in one stretch) is where naive implementations break. This package gets that right out of the box.
PHP usage
use PhDevUtils\Dates\{BusinessDays, Format}; BusinessDays::isBusinessDay('2026-05-25'); // true (Monday) BusinessDays::isBusinessDay('2026-12-25'); // false (Christmas) BusinessDays::addBusinessDays('2026-12-23', 1); // '2026-12-28' (skips Christmas Eve + Christmas + weekend) BusinessDays::businessDaysBetween('2026-12-21', '2026-12-31'); // 5 Format::filipino('2026-05-25'); // 'Lunes, 25 ng Mayo 2026' Format::filipino('2026-05-25', ['style' => 'short']); // 'Lun, 25 Mayo 2026' Format::month(5); // 'Mayo' Format::day(1); // 'Lunes'
JS usage
A parity JavaScript/TypeScript package is published as @ph-dev-utils/dates:
import { isBusinessDay, addBusinessDays, businessDaysBetween, formatFilipino } from '@ph-dev-utils/dates'; addBusinessDays('2026-12-23', 1); // '2026-12-28' businessDaysBetween('2026-12-21', '2026-12-31'); // 5 formatFilipino('2026-05-25'); // 'Lunes, 25 ng Mayo 2026'
Options for business-day functions
saturdayIsBusinessDay/sundayIsBusinessDay— for 6- or 7-day workweeks (default false)extraNonBusinessDates— company-specific shutdown daysexcludeSpecialWorking— also exclude "special working" proclaimed days (NOT excluded by default — those are normal work days at 100% pay)
Date type handling
Public APIs accept either ISO YYYY-MM-DD strings or native DateTimeInterface. Internally everything is normalized to ISO strings to avoid timezone foot-guns. Functions return ISO strings — wrap them in your call site if you need richer types.
⚠️ "Special working" days
PH proclaims some days as "special working" (work proceeds at 100% pay, no premium) — e.g. Holy Saturday some years, or specific local holidays. They ARE business days by default. Set excludeSpecialWorking: true if your business actually closes on them.
License
MIT