2017 © Pedro Peláez
 

library php-time

php time conversion

image

dgame/php-time

php time conversion

  • Wednesday, November 22, 2017
  • by Dgame
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13,118 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 14 % Grown

The README.md

php-time

Convert TimeUnits to other TimeUnits in no time.

Seconds:

seconds(300)->inMinutes()->equalsAmount(5);

Minutes:

minutes(60)->inSeconds()->equalsAmount(3600);
minutes(60)->inHours()->equalsAmount(1);

Hours:

hours(24)->inMinutes()->equalsAmount(1440);
hours(24)->inDays()->equalsAmount(1);

Days:

days(7)->inHours()->equalsAmount(168);
days(7)->inWeeks()->equalsAmount(1);

Weeks:

weeks(12)->inDays()->equalsAmount(84);

Months:

months(12)->inYears()->equalsAmount(1);

Years:

years(1)->inWeeks()->equalsAmount(52);
years(2)->inMonths()->equalsAmount(24);

Compare TimeUnits:

hours(24)->equals(days(1));
days(1)->equals(hours(24));
years(1)->equals(days(365));
weeks(1)->equals(days(7));

Add / Subtract TimeUnits:

days(1)->add(hours(24))->equals(days(2));
hours(24)->subtract(days(0.5))->equals(hours(12));
hours(1)->equals(minutes(60));

Get specific informations about a Month / Year

There is a Month and a Year class (note the missing s at the end) to access precise informations about a specific year or a specific month in a specific year:, (*1)

Month:

Month::Of('Feb', 2015)->inDays()->equalsAmount(28);
Month::Of('Feb', 2015)->inWeeks()->equalsAmount(4);
Month::Of('Feb', 2016)->inDays()->equalsAmount(29);
Month::Of('Jun', 2016)->inDays()->equalsAmount(30);
Month::Of('Jun', 2016)->inWeeks()->equalsAmount(4.28571);

Year:

Year::Of(2016)->isLeapyear();
Year::Of(2015)->inDays()->equalsAmount(365);
Year::Of(2016)->inDays()->equalsAmount(366);
Year::Of(2015)->inWeeks()->equalsAmount(52.142857142857);
Year::Of(2016)->inWeeks()->equalsAmount(52.285714285714);

Represent a TimeUnit in individual units

$unit = new TimeUnits(days(1000));

$this->assertTrue($unit->getYears()->equalsAmount(2));
$this->assertTrue($unit->getMonths()->equalsAmount(8));
$this->assertTrue($unit->getWeeks()->equalsAmount(3));
$this->assertTrue($unit->getDays()->equalsAmount(5));
$this->assertTrue($unit->getHours()->equalsAmount(11));
$this->assertTrue($unit->getMinutes()->equalsAmount(33));
$this->assertTrue($unit->getSeconds()->equalsAmount(20));
$unit = new TimeUnits(hours(4.5));

$this->assertTrue($unit->getYears()->equalsAmount(0));
$this->assertTrue($unit->getMonths()->equalsAmount(0));
$this->assertTrue($unit->getWeeks()->equalsAmount(0));
$this->assertTrue($unit->getDays()->equalsAmount(0));
$this->assertTrue($unit->getHours()->equalsAmount(4));
$this->assertTrue($unit->getMinutes()->equalsAmount(30));
$this->assertTrue($unit->getSeconds()->equalsAmount(0));
$unit = new TimeUnits(minutes(525));

$this->assertTrue($unit->getYears()->equalsAmount(0));
$this->assertTrue($unit->getMonths()->equalsAmount(0));
$this->assertTrue($unit->getWeeks()->equalsAmount(0));
$this->assertTrue($unit->getDays()->equalsAmount(0));
$this->assertTrue($unit->getHours()->equalsAmount(8));
$this->assertTrue($unit->getMinutes()->equalsAmount(45));
$this->assertTrue($unit->getSeconds()->equalsAmount(0));

The Versions

22/11 2017

dev-master

9999999-dev https://github.com/php-time

php time conversion

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

date time timer clock time conversion

01/06 2017

v0.4.2

0.4.2.0 https://github.com/php-time

php time conversion

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

date time timer clock time conversion

01/05 2017

v0.4.1

0.4.1.0 https://github.com/php-time

php time conversion

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

date time timer clock time conversion

21/02 2017

v0.4.0

0.4.0.0 https://github.com/php-time

php time conversion

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

date time timer clock time conversion

02/02 2017

v0.3.0

0.3.0.0 https://github.com/php-time

php time conversion

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

date time timer clock time conversion

10/01 2017

v0.2.0

0.2.0.0 https://github.com/php-time

php time conversion

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

date time timer clock time conversion

18/09 2016

0.1.2

0.1.2.0 https://github.com/php-time

php time conversion

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

date time timer clock time conversion

05/08 2016

v0.1.1

0.1.1.0 https://github.com/php-time

php time conversion

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

18/06 2016

v0.1.0

0.1.0.0 https://github.com/php-time

php time conversion

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires