xenon/datetime-calc

This is a date time calculation library for php based on Carbon

v0.0.1-alpha 2023-12-28 21:52 UTC

This package is auto-updated.

Last update: 2024-10-28 23:51:32 UTC


README

Breakdown and Splitting Time Range

    $time = new TimeBreakDown(
        startTime: '11:00', 
        endTime: '12:00'
    );
    $time->setIntervalMinute(30);
    $time->setBreakDuration(2);
    $time->includeBreaks(1);
    $data = $time->getIntervals(
        breakString: 'is_break',
        startTimeFormat: 'H:i:s',
        endTimeFormat: 'H:i:s'
    );

This will print below time split with 30mins breaks in every stage and it has 2mins break als

Array
(
    [0] => Array
        (
            [start] => 11:00:00
            [end] => 11:30:00
        )

    [1] => Array
        (
            [start] => 11:30:00
            [end] => 11:32:00
            [is_break] => 1
        )

    [2] => Array
        (
            [start] => 11:32:00
            [end] => 12:02:00
        )

    [3] => Array
        (
            [start] => 12:02:00
            [end] => 12:04:00
            [is_break] => 1
        )

)