2017 © Pedro Peláez
 

library date-helper

Date helper

image

drlenux/date-helper

Date helper

  • Wednesday, May 2, 2018
  • by drlenux
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Latest Stable Version Total Downloads Build Status php version scrutinizer scrutinizer scrutinizer, (*1)

Author: DrLenux, (*2)

License: MIT, (*3)

Allow method DateChange:, (*4)

interface DateChange {
    function addDay(int $count = 1): self;
    function addMonth(int $count = 1): self;
    function addYear(int $count = 1): self;
    function addHour(int $count = 1): self;
    function addMinute(int $count = 1): self;
    function addSeconds(int $count = 1): self;

    function subDay(int $count = 1): self;
    function subMonth(int $count = 1): self;
    function subYear(int $count = 1): self;
    function subHour(int $count = 1): self;
    function subMinute(int $count = 1): self;
    function subSeconds(int $count = 1): self;

    function diff(DateChange $date): DateInterval|bool;
}

Example DateChange:, (*5)

<?php

use DrLenux\DataHelper\DateChange; 

$date = (new DateChange('2012-12-12'))
            ->addYear()
            ->addMonth(2)
            ->subDay();

Allow method DateFill:, (*6)

interface DateFill {
    function to(string $to)
    function from(string $from)
    function inclusiveStart(bool $status)
    function inclusiveEnd(bool $status)
    function interval(string $interval)
    function format(string $format)
    function timezone(\DateTimeZone $timezone = null)

    function fill()
    function getErrors()
}

Example DateFill:, (*7)

<?php

use DrLenux\DataHelper\DateFill;

$fillArray = (new DateFill())
    ->from('2011-01-01')
    ->to('2011-01-02')
    ->interval(DateFill::INTERVAL_HOUR)
    ->fill();

/*
return [
    '2011-01-01 01:00:00',
    ...
    '2011-01-01 23:00:00'
];
 */

Example Interval:, (*8)

<?php

use DrLenux\DataHelper\DateFill;

(new DateFill())
    ->from('2011-10-09 23:59:59')
    ->to('2011-10-09 23:50:00')
    ->interval('PT2M') // every 2 minute
    ->format('H:i:s')
    ->fill(); 

/*
return [
    '23:57:59',
    '23:55:59',
    '23:53:59',
    '23:51:59'
];
*/

Example Diff:, (*9)

<?php

use DrLenux\DataHelper\DateChange;

$date1 = new DateChange('01-01-2018');
$date2 = new DateChange('01-01-2017');

$diff = $date1->diff($date2);
echo $diff->days;

/*
return 365;
*/

The Versions

02/05 2018

dev-master

9999999-dev

Date helper

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

02/05 2018

0.2.2

0.2.2.0

Date helper

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

02/05 2018

0.2.1

0.2.1.0

Date helper

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

02/05 2018

0.2

0.2.0.0

Date helper

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires