nowo-tech/relative-time-bundle

Format DateTime values as localized relative time strings (e.g. just now, 5 minutes ago) for Symfony and Twig.

Maintainers

Package info

github.com/nowo-tech/RelativeTimeBundle

Documentation

Language:Shell

Type:symfony-bundle

pkg:composer/nowo-tech/relative-time-bundle

Transparency log

Fund package maintenance!

HecFranco

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-07-18 16:03 UTC

This package is auto-updated.

Last update: 2026-07-18 17:08:33 UTC


README

CI Packagist Version Packagist Downloads License PHP Symfony GitHub stars Coverage

Found this useful? Install from Packagist and give it a star on GitHub.

Symfony bundle that formats a DateTime (or timestamp / date string) as a localized relative time string: just now, 5 minutes ago, in 2 hours, hace un momento, hace 3 días, and so on.

Features

  • RelativeTimeFormatter service with past and future wording
  • Twig filters/functions: relative_time and ago
  • i18n catalogues for en, es, it, fr, pt, de, nl (domain NowoRelativeTimeBundle)
  • Configurable just_now_threshold_seconds, max_unit, locale and timezone defaults
  • App-level translation overrides (REQ-I18N-001)

Documentation

Additional documentation

Quick example

use Nowo\RelativeTimeBundle\Service\RelativeTimeFormatter;

public function __construct(private RelativeTimeFormatter $relativeTime) {}

public function label(\DateTimeInterface $createdAt): string
{
    return $this->relativeTime->format($createdAt, 'es');
    // → "hace 5 minutos"
}
{{ entity.createdAt|relative_time }}
{{ entity.createdAt|ago('es') }}
{{ relative_time(entity.publishedAt, 'fr') }}

Requirements

  • PHP >= 8.2, < 8.6
  • Symfony 7.4+ or 8.x (symfony/translation, Twig)
  • Twig 3.8+ or 4.x

Tests and coverage

Language Lines (approx.) Command
PHP ~100% make test-coverage
TypeScript N/A
Python N/A
make test
make test-coverage
make validate-translations
make release-check

PHP coverage target is ~100% (currently ~100%; see Release).

Demo

make -C demo up-symfony8
# Demo started at: http://localhost:8008

FrankenPHP worker mode for production demos is documented in DEMO-FRANKENPHP.md.

Version policy

The Composer package name is nowo-tech/relative-time-bundle. Source code and issues are in the GitHub repository nowo-tech/RelativeTimeBundle.

We follow Semantic Versioning. See Changelog for release notes. Security support by major version is described in the Security policy.

License

MIT. See LICENSE.