PHPackages                             brekitomasson/seconds - 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. brekitomasson/seconds

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

brekitomasson/seconds
=====================

Convert any duration to seconds quickly.

v1.2.0(5mo ago)11.3kMITPHPPHP ^8.1

Since May 11Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/BrekiTomasson/Seconds)[ Packagist](https://packagist.org/packages/brekitomasson/seconds)[ RSS](/packages/brekitomasson-seconds/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

Seconds
=======

[](#seconds)

PHP Library to simplify stuff when all you want is a number of seconds.

Will be kept super simple as it's mainly just a single `Enum` class with a bunch of constants and helper functions that all return an integer. Don't expect too many new features in upcoming patches and updates, since it's just a simple helper library that does one thing and one thing only.

Usage
=====

[](#usage)

Usage is super simple, as one would expect. Just call the static method for the appropriate input type and give it the number, and it will return the number of seconds. No more `60 * 60 * 24 * 7` to get the number of seconds in a week. Just call `Seconds::fromWeeks(1)` and you're good to go.

For example:

```
Seconds::fromMinutes(1);
// 60

Seconds::fromMinutes(32);
// 1920

Seconds::fromHours(3);
// 180

Seconds::fromDays(3)
// 259200

Secnds::fromWeeks(4)
// 2419200
```

Limitations and Constraints
===========================

[](#limitations-and-constraints)

Since I want to keep things simple, the output is limited to positive numbers. This means that even if the input is negative, the output will be positive:

```
Seconds::fromMinutes(-1);
// 60
```

Also, the input for all methods must be a whole number, so you cannot check how many seconds are in 3.5 hours unless you do something like this:

```
Seconds::fromHours(3) + Seconds::fromMinutes(30);
// 12600
```

Finally, the longest available time period is weeks, since both months and years have a variable length. If you want to figure out how many seconds are in three months, you'll have to do something like one of these examples:

```
use Breki\Seconds;Seconds::fromWeeks(13);
// 7862400

Seconds::fromDays(31 + 30 + 31);
// 7948800
```

Upcoming Features and Future Development Ideas
==============================================

[](#upcoming-features-and-future-development-ideas)

Right now, I have very little planned for this library as it does what it's supposed to do. The only thing that I can imagine is maybe adding support for calculating the seconds between two dates, but that's not really the purpose of this library. If you want to do that, you should probably use the `Carbon` library and do something like this:

```
$date1 = Carbon::parse('2023-09-23 07:14:00 UTC')
$date2 = Carbon::parse('2023-12-31 23:59:59 UTC')

$date1->diffInSeconds($date2)
> 8613959
```

Of course, if you have any thoughts or ideas, feel free to open an issue or throw a Pull Request my way, and we'll see what comes of it!

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance70

Regular maintenance activity

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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

Every ~310 days

Total

4

Last Release

169d ago

PHP version history (2 changes)v1.0.0PHP &gt;=8.1

v1.1.1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/2005bc0510625184565d645acd62c9e54cbb1b692586276728e2293d2ce9b831?d=identicon)[Breki](/maintainers/Breki)

---

Top Contributors

[![BrekiTomasson](https://avatars.githubusercontent.com/u/7026735?v=4)](https://github.com/BrekiTomasson "BrekiTomasson (6 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/brekitomasson-seconds/health.svg)

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

PHPackages © 2026

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