PHPackages                             roukmoute/timespan - 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. roukmoute/timespan

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

roukmoute/timespan
==================

Represents a time interval

v0.1.0(1y ago)01MITPHPPHP ^8.3

Since Jan 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/roukmoute/TimeSpan)[ Packagist](https://packagist.org/packages/roukmoute/timespan)[ RSS](/packages/roukmoute-timespan/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

TimeSpan v0.1
-------------

[](#timespan-v01)

Represents a time interval

### Key Features:

[](#key-features)

- **Precise time representation** using ticks (nanoseconds) as the base unit.
- Support for converting between different time units (days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds).

### Available Methods:

[](#available-methods)

#### Time Conversion:

[](#time-conversion)

- `totalDays()`: Returns the total duration in days.
- `totalHours()`: Returns the total duration in hours.
- `totalMinutes()`: Returns the total duration in minutes.
- `totalSeconds()`: Returns the total duration in seconds.
- `totalMilliseconds()`: Returns the total duration in milliseconds.

#### Instance Creation:

[](#instance-creation)

- `TimeSpan::zero()`: Creates an instance representing a duration of 0.
- `TimeSpan::fromDays(float $days, ...)`: Creates an instance from a duration in days.
- `TimeSpan::fromHours(float $hours, ...)`: Creates an instance from a duration in hours.
- `TimeSpan::fromMinutes(float $minutes, ...)`: Creates an instance from a duration in minutes.
- `TimeSpan::fromSeconds(float $seconds, ...)`: Creates an instance from a duration in seconds.
- `TimeSpan::fromMilliseconds(float $milliseconds, ...)`: Creates an instance from a duration in milliseconds.
- `TimeSpan::fromMicroseconds(float $microseconds)`: Creates an instance from a duration in microseconds.

#### Manipulation and Comparison:

[](#manipulation-and-comparison)

- `compareTo(?TimeSpan $timeSpan2)`: Compares two `TimeSpan` instances.
- `addTo(TimeSpan $timeSpan)`: Adds a duration to the current instance.
- `duration()`: Returns the absolute value of the current duration.
- `equals(?TimeSpan $t2)`: Checks if two `TimeSpan` instances are equal.
- `compare(TimeSpan $timeSpan1, ?TimeSpan $timeSpan2)`: Compares two durations in ticks.
- `negate(): TimeSpan`: Returns a new instance representing the negation of the current duration.

#### Tick-Based Properties:

[](#tick-based-properties)

- `ticks()`: Returns the duration in ticks.
- `days()`: Returns the whole number of days.
- `hours()`: Returns the number of hours in the current day.
- `minutes()`: Returns the number of minutes in the current hour.
- `seconds()`: Returns the number of seconds in the current minute.
- `milliseconds()`: Returns the number of milliseconds in the current second.
- `microseconds()`: Returns the number of microseconds in the current millisecond.
- `nanoseconds()`: Returns the number of remaining nanoseconds.

#### Constants:

[](#constants)

- Definitions of relationships between time units, such as:
    - `TICKS_PER_SECOND`, `TICKS_PER_MINUTE`, `MICROSECONDS_PER_SECOND`, etc.
    - Limits: `MIN_TICKS` and `MAX_TICKS`.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance42

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

483d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a864b67689c18f73803e34b6c4e269ab08395067ad635e1382ed96cc76f596a0?d=identicon)[roukmoute](/maintainers/roukmoute)

---

Top Contributors

[![roukmoute](https://avatars.githubusercontent.com/u/2140469?v=4)](https://github.com/roukmoute "roukmoute (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/roukmoute-timespan/health.svg)

```
[![Health](https://phpackages.com/badges/roukmoute-timespan/health.svg)](https://phpackages.com/packages/roukmoute-timespan)
```

###  Alternatives

[jg/kirby-wrappers

Kirby Wrapper Tags

181.8k](/packages/jg-kirby-wrappers)

PHPackages © 2026

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