ordinary/datetime

Library with DateTimeImmutable extension for easy time operations.

1.2.0 2023-02-28 10:57 UTC

This package is auto-updated.

Last update: 2024-04-28 13:30:06 UTC


README

This library provides an extended DateTimeImmutable class that provides additional functionality.

Getting Started

Install using composer.

composer require ordinary/datetime

Usage

$dateTime = new \Ordinary\DateTime\DateTimeImmutable();
var_dump([
    'Start of day' => $dateTime->startOfDay()->format('c'),
    'End of day' => $dateTime->endOfDay()->format('c'),
    'Is leap year' => $dateTime->leapYear(),
    'Is same minute' => $dateTime->isSameMinute(new DateTime()),
    'Is before' => $dateTime->isBefore(new DateTime()),
    'Current hour' => $dateTime->hour(),
    'Day of Week' => $dateTime->dayOfWeekEnum(),
]);