leaditin / moment
A simple PHP API for Time, DateTime and DateRange.
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/leaditin/moment
Requires
- php: ^8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.4
- phpunit/phpunit: ^9.6
This package is auto-updated.
Last update: 2025-10-04 11:31:26 UTC
README
A simple PHP API for Time, DateTime and DateRange.
Installation
The preferred method of installation is via Composer. Run the following command to install the latest version of a package and add it to your project's composer.json
:
composer require leaditin/moment
Usage
Instantiate Time object
use \Leaditin\Moment\Time; $time = Time::fromSeconds(7200); $time = Time::fromString('12:25');
Instantiate DateTime object
use \Leaditin\Moment\DateTime; $now = new DateTime(); $today = new DateTime('now', null, DateTime::TYPE_DATE); $past = new DateTime('26 Jul 1984', null, DateTime::TYPE_DATE);
Instantiate DateRange object
use \Leaditin\Moment\{DateTime, DateRange}; $range = new DateRange(new DateTime('2016-01-01 00:00:00'), new DateTime('2016-12-31 23:59:59')); $infinityLeft = new DateRange(null, new DateTime()); $infinityRight = new DateRange(new DateTime(), null); $infinity = new DateRange();
Credits
License
Released under MIT License - see the License File for details.