PHPackages                             itvisionsy/php-time - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. itvisionsy/php-time

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

itvisionsy/php-time
===================

Time management class

1761PHP

Since Oct 4Pushed 9y ago1 watchersCompare

[ Source](https://github.com/itvisionsy/php-time)[ Packagist](https://packagist.org/packages/itvisionsy/php-time)[ RSS](/packages/itvisionsy-php-time/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

php-time
========

[](#php-time)

A PHP class to easily create and maintain time values. You can create the object from a string like "1:22:13.212" or timestamps and it will automatically parse and fetch values.

You can then update the values, or convert it into strings or timestamps.

Creating the object
-------------------

[](#creating-the-object)

You can create the object from empty value, or from a string, or a timestamp. i.e.

```
$time1 = new \ItvisionSy\Time\Time(); //Time is set to "0:0:0.000"
$time2 = new \ItvisionSy\Time\Time("1:22:18.212");
$time3 = new \ItvisionSy\Time\Time(36232518212);
```

Also you can use the `make($time)` factory method:

```
$time1 = \ItvisionSy\Time\Time::make();
$time2 = \ItvisionSy\Time\Time::make("12:46:36.897");
$time3 = \ItvisionSy\Time\Time::make(3600000);
```

### Time string

[](#time-string)

Time string is a string with 4 parts as follows: `h[:i[:s[.m]]]`. I.e:

```
\ItvisionSy\Time\Time::make('3')->format(); //3:0:0.0
\ItvisionSy\Time\Time::make('3:30')->format(); //3:30:0.0
\ItvisionSy\Time\Time::make('3:30:22')->format(); //3:30:22.0
\ItvisionSy\Time\Time::make('3:30:22.123')->format(); //3:30:22.123
```

If milliseconds digits are more than 3, only first 3 will be used. Also, you can use irregular (overflown) values and it will be automatically converted into the next unit. i.e.

```
\ItvisionSy\Time\Time::make('3:90')->format(); //4:30:0.0
\ItvisionSy\Time\Time::make('0:180')->format(); //3:0:0.0
```

Setting values
--------------

[](#setting-values)

You can use the methods: `hours($value)`, `minutes($value)`, `seconds($value)`, or `millis($value)` to update the value. The `$value` parameter can be either an integer which will replace the old value, or a string preceded with "+" or "-" to alter the current value. i.e.

```
$time = \ItvisionSy\Time\Time::make()->hours(4); //sets the hours to 4
$time->hourse("+3"); //sets the hours to 7 (4+3)
$time->hours(0)->minutes(128)->seconds(61)->format(); //returns 2:9:1.000
```

You can also use the direct assignment which will call the previous methods. i.e.

```
$time = \ItvisionSy\Time\Time::make("1:2:3.4");
$time->hours = 33;
$time->seconds = "-22";
```

Or you can use the parser method

```
$time->parseString("22:11:12.123");
```

Getting values
--------------

[](#getting-values)

You can either use the methods or the properties

```
$time->hours; // === $time->hours()
$time->minutes; // === $time->minutes()
$time->seconds; // === $time->seconds()
$time->millis; // === $time->millis()
```

Utilities
---------

[](#utilities)

### Formatting

[](#formatting)

`format(boolean $leadingZeros = false)`

```
$time = \ItvisionSy\Time\Time::make("6:3:7.23");
$time->minutes("+123");
$time->format(); //"8:6:7.23"
$time->format(true); //"8:06:07.023"
```

### Representing

[](#representing)

You can represent the timestamp in a unit like hours or minutes.

```
$time = \ItvisionSy\Time\Time::make("2:30:00.000");
```

### Comparing

[](#comparing)

\####Diff function

```
use \ItvisionSy\Time\Time;
Time::make('3')->diff(Time::make(2))->inHours; //3:0:0.0
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/11ac511b34acf3f7e9a138d3b1a0a868303b376ab991bb176e8ea474857a0e57?d=identicon)[mhh1422](/maintainers/mhh1422)

---

Top Contributors

[![mhh1422](https://avatars.githubusercontent.com/u/499764?v=4)](https://github.com/mhh1422 "mhh1422 (13 commits)")

### Embed Badge

![Health badge](/badges/itvisionsy-php-time/health.svg)

```
[![Health](https://phpackages.com/badges/itvisionsy-php-time/health.svg)](https://phpackages.com/packages/itvisionsy-php-time)
```

###  Alternatives

[stackkit/laravel-google-cloud-scheduler

33266.0k](/packages/stackkit-laravel-google-cloud-scheduler)[wapplersystems/core-upgrader

Run upgrade wizards for multiple TYPO3 versions at once and clean up the system

1026.0k1](/packages/wapplersystems-core-upgrader)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
