PHPackages                             dtl/time-distance-bundle - 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. dtl/time-distance-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

dtl/time-distance-bundle
========================

Provides TWIG helpers for distance and time stuff

023PHP

Since Apr 15Pushed 13y ago1 watchersCompare

[ Source](https://github.com/dantleech/TimeDistanceBundle)[ Packagist](https://packagist.org/packages/dtl/time-distance-bundle)[ RSS](/packages/dtl-time-distance-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Disatance and Time Bundle
=========================

[](#disatance-and-time-bundle)

This bundle adds some useful time and distance integrations:

- Twig filters
    - format\_distance
    - seconds\_to\_stopwatch
    - average\_pace
    - average\_speed
- Form types
    - Distance form type
    - Stopwatch form type

Note that when we talk about "stopwatch" here it refers to the format of the text, ie. hh:mm:ss.

Configuration
-------------

[](#configuration)

By default all distances are assumed to be normalized as meters, you can change this value in the configuration as follows:

```
dtl_time_distance:
    normalized_distance_unit: m

```

Twig Filters
============

[](#twig-filters)

format\_distance

```

Convert the given normalized distance to the specified unit:

    {# Format 20km (in meters) to miles #}
    {{ 2000|format_distance('miles') }}

    {# Format 20km (in meters) to foot with a precision of 4 #}
    {{ 2000|format_distance('ft', 4) }}

seconds_to_stopwatch
-------------------

Format a given number of seconds as "stopwatch" (hh:mm:ss):

    {# 1 hour will display as 01:00:00 #}
    {{ 3600|seconds_to_stopwatch }}

    {# 2 seconds will display as 00:00:02 #}
    {{ 2|seconds_to_stopwatch }}

    {# 1 week will display as 168:00:00 #}
    {{ 604800|seconds_to_stopwatch }}

average_pace
------------

Format average pace (i.e. time per distance unit) for given time and distance:

    {# If you ran 10k in 47 minutes you would do 00:07:34 - 7 minutes, 34 seconds per mile #}
    {{ 2820|average_pace(10, 'miles') }}

    {# Default is km, but will accept any of the distance units #}
    {{ 2820|average_pace(10) }}

average_speed
-------------

Format average speed acccording to given distance unit:

    {# If you ran 10k in 47 minutes you run at 7.93 miles per hour #}
    {{ 2820|average_speed(10, 'miles') }}

Form Types
==========

distance
--------

The distance form type accepts the following formats

- 12k - 12 kilometers
- 12km - 12 kilometers
- 12 miles - 12 miles
- 12m - 12 miles
- 12 - 12 kilometers

All values are converted to *kilometers* internally.

stopwatch
---------

The stopwatch type accepts all values accepted by `mktime`
with the addition of the stopwatch format `hh:mm:ss`.

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

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/24ec7d5d6b7ea54007be5d7b4f43800381cc1e22929f7d2276fba30e497fdfa6?d=identicon)[dantleech](/maintainers/dantleech)

---

Top Contributors

[![dantleech](https://avatars.githubusercontent.com/u/530801?v=4)](https://github.com/dantleech "dantleech (7 commits)")

### Embed Badge

![Health badge](/badges/dtl-time-distance-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/dtl-time-distance-bundle/health.svg)](https://phpackages.com/packages/dtl-time-distance-bundle)
```

###  Alternatives

[magepal/magento2-checkout-success-misc-script

Add Miscellaneous HTML and JavaScript codes to Magento2 checkout confirmation page

2917.7k](/packages/magepal-magento2-checkout-success-misc-script)

PHPackages © 2026

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