francerz/datetime-tools

Date Time Tools for PHP

v0.1.3 2023-04-20 19:46 UTC

This package is auto-updated.

Last update: 2024-11-20 23:44:22 UTC


README

A set of PHP functions to handle date and time units.

Class DateTimeHelper

class DateTimeHelper
{
    public static function toDateTime($datetime): ?DateTime;

    public static function toDateTimeImmutable($datetime): ?DateTimeImmutable;

    public static function max($datetimes): ?DateTime;

    public static function min($datetimes): ?DateTime;
}
class DateIntervalHelper
{
    public static function create($y = 0, $m = 0, $d = 0, $h = 0, $i = 0, $s = 0);
}

Class DateTimeRange

class DateTimeRange
{
    public function __construct($start, $end);

    public function getStart(): ?DateTime;

    public function getEnd(): ?DateTime;

    public function intersect($datetime): bool;

    public function intersectRange(DateTimeRange $range, bool $withoutLimit = false): bool;

    public function getRangeIntersect(DateTimeRange $range): DateTimeRange|null;

    public function countSeconds(): int;
    
    public function countWeekDays(): int[];
}