danbettles / php-medjool
Like PHP dates, only juicier
v1.1.0
2026-06-23 20:08 UTC
Requires
- php: ^8.3
Requires (Dev)
- danbettles/codesniffer-standard: ^3.0.0
- phpstan/phpstan: ^2.2.2
- phpunit/phpunit: ^12.5.30
- squizlabs/php_codesniffer: ^4.0.1
README
A simple extension of PHP's Date/Time module, to make working with dates and times a little smoother. In general, I think Date/Time is actually pretty great. In some cases, though, things can feel a little clunky, so that's why Medjool is "like PHP dates, only juicier".
Overview
At Medjool's heart is the Date class, which is a Value Object—like DateTimeImmutable.
Of note:
- The constructor accepts a date-time string, an integer timestamp, a
DateTimeImmutable, or aDateTime, so there's no need to use different methods to create an instance. - Provides
toIsoDateTimeString(),toMysqlDateString(), andtoMysqlDateTimeString()to easily format the date. getComponents()gives you access to all/selected date and time components in one go.startOf()and its alias,trunc(), resets the date to the specified date component.isInPast()andisInFuture()simply read better.setTimezone()gives you the option to preserve the time.