leaditin/moment

A simple PHP API for Time, DateTime and DateRange.

2.0.1 2024-10-04 09:17 UTC

This package is auto-updated.

Last update: 2024-11-04 09:32:39 UTC


README

A simple PHP API for Time, DateTime and DateRange.

Build Status Code Quality Code Coverage Latest Version PDS Skeleton

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.