PHPackages                             dcaswel/time-converter - 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. dcaswel/time-converter

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

dcaswel/time-converter
======================

A PHP package for converting a unit of time into another unit of time.

1.0.0(3y ago)034MITPHPPHP ^8.0

Since Dec 11Pushed 3y ago1 watchersCompare

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

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

Time Converter
==============

[](#time-converter)

A fluent PHP package for converting one unit of time into another unit of time.

Have you ever wanted an elegant way to get a certain amount of time worth of seconds? Let's say you're using a caching system where you need to set the ttl in a number of seconds. Does this look familiar?

```
//One day's worth of seconds
$ttl = 24 * 60 * 60;
```

Have you ever wanted to have something that was easier to read that is self documenting. That's where this package comes in. Here's the equivalent line of code using Time Converter:

```
use Dcaswel\TimeConverter\TimeConverter;

$ttl = TimeConverter::convert()->oneDay()->toSeconds();
```

Now, let's take a deeper look...

Installation
------------

[](#installation)

```
composer require dcaswel/time-converter

```

Usage
-----

[](#usage)

This package can be used for converting almost any length of time into any other length of time.

### Examples

[](#examples)

```
TimeConverter::convert()->days(5)->toSeconds(); //432000
TimeConverter::convert()->years(2)->toMonths(); //24
TimeConverter::convert()->weeks(20)->toDays(); //140
...
```

*Note: In order to keep the numbers whole, a month is considered 28 days.*

You can also combine methods to get a more precise time:

```
TimeConverter::convert()->weeks(2)->days(5)->toDays(); //19
```

For any method in the class, you can also call a singular version of it by prepending `one` to the beginning and removing the `s`. For example:

- `weeks()` can be `oneWeek()`
- `days()` can be `oneDay()`
- etc.

API
---

[](#api)

```
/**
 * Methods to set the time being converted
 */

public function minutes(int $number)
public function hours(int $number)
public function days(int $number)
public function weeks(int $number)
public function months(int $number)
public function years(int $number)

/**
 * Methods to get the number you want to convert to
 */

public function toSeconds(): int|float
public function toMinutes(): int|float
public function toHours(): int|float
public function toDays(): int|float
public function toWeeks(): int|float
public function toMonths(): int|float
public function toYears(): int|float
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

1245d ago

### Community

Maintainers

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

---

Top Contributors

[![dcaswel](https://avatars.githubusercontent.com/u/20131539?v=4)](https://github.com/dcaswel "dcaswel (2 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/dcaswel-time-converter/health.svg)

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

PHPackages © 2026

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