/php-datetime-tools

Primary LanguagePHPMIT LicenseMIT

Date and Time Tools

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[];
}