PHPackages                             juniq/yii2-helper-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. juniq/yii2-helper-time

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

juniq/yii2-helper-time
======================

A useful helper function for time calculations - especially for durations - for Yii Framework 2

1.1(10y ago)32.7k3[1 PRs](https://github.com/juniq/yii2-helper-time/pulls)BSD-3-ClausePHP

Since Aug 17Pushed 8y ago1 watchersCompare

[ Source](https://github.com/juniq/yii2-helper-time)[ Packagist](https://packagist.org/packages/juniq/yii2-helper-time)[ Docs](https://github.com/juniq/yii2-helper-time)[ RSS](/packages/juniq-yii2-helper-time/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

yii2-helper-time
================

[](#yii2-helper-time)

Description
-----------

[](#description)

A useful helper function for time calculations - especially for durations - for Yii Framework 2. You can use the function `Time::formatDuration` to convert seconds into human readable duration strings like: 5 days 8 hours 19 minutes 11 seconds

How to install
--------------

[](#how-to-install)

### Composer

[](#composer)

The easiest way to install this package is to use composer. If you don't have composer get it here:

Now you can run the following commands in your *root project directory*:

```
composer require "juniq/yii2-helper-time" "*"

```

or (depending on your installation type)

```
php composer.phar require "juniq/yii2-helper-time" "*"

```

### Manually download

[](#manually-download)

Download the latest version here:

How to use it
-------------

[](#how-to-use-it)

To convert seconds into human readable duration strings, you can use the following function:

```
Time::formatDuration($time, $length = 'short', $custom_units = false, $separator = ', ')

```

ParameterTypeRequired?Description$timeIntegeryesThe time in seconds you want to format.$lengthStringoptionalThe display lenghts. Use "short" or "long".$custom\_unitsArray/BooleanoptionalTime units to display. Pass "false" to use all time units. Possible values: y, m, w, d, h, i, s.$separatorStringoptionalThe separator sign between time units.Examples
--------

[](#examples)

```
use juniq\helper\Time;

$time_in_seconds = 5781; // 1 hour 36 minutes, 21 seconds

echo Time::formatDuration($time_in_seconds);
// ouput: 1 hour 36 minutes, 21 seconds

echo Time::formatDuration($time_in_seconds, 'long', ['h','i','s'], 'long');
// ouput: 1 hour 36 minutes 21 seconds

echo Time::formatDuration($time_in_seconds, 'short', ['h','i','s'], ',');
// output: 36 minutes, 21 seconds

echo Time::formatDuration($time_in_seconds, 'short',  ['i','s'], ',');
// output: 96 m, 21 s

```

License
-------

[](#license)

Look at 'LICENSE.md' file

About &amp; Copyright
---------------------

[](#about--copyright)

Copyright by JUNIQ GmbH &amp; Co. KG. Author: Richard Jung

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 93.8% 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 ~0 days

Total

2

Last Release

3921d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/49c38526f4d793412de99d34150c3122ece352b3b097e6219743edf307b3b1ca?d=identicon)[juniq](/maintainers/juniq)

---

Top Contributors

[![Jusophos](https://avatars.githubusercontent.com/u/450811?v=4)](https://github.com/Jusophos "Jusophos (15 commits)")[![developer-av](https://avatars.githubusercontent.com/u/15675868?v=4)](https://github.com/developer-av "developer-av (1 commits)")

---

Tags

helpertimeyii2extensionyiibootstraputilitiesduration

### Embed Badge

![Health badge](/badges/juniq-yii2-helper-time/health.svg)

```
[![Health](https://phpackages.com/badges/juniq-yii2-helper-time/health.svg)](https://phpackages.com/packages/juniq-yii2-helper-time)
```

###  Alternatives

[kartik-v/yii2-helpers

A collection of useful helper functions for Yii Framework 2.0

883.0M29](/packages/kartik-v-yii2-helpers)[kartik-v/yii2-date-range

An advanced Yii 2 date range picker input for based on bootstrap-daterangepicker plugin.

894.4M42](/packages/kartik-v-yii2-date-range)[kartik-v/yii2-widget-timepicker

Enhanced Yii2 wrapper for the bootstrap timepicker plugin (sub repo split from yii2-widgets)

404.9M14](/packages/kartik-v-yii2-widget-timepicker)

PHPackages © 2026

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