Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eschmar/time-ago-bundle
Provides a simple twig filter for expressing time difference in words.
https://github.com/eschmar/time-ago-bundle
symfony symfony-bundle twig twig-extension
Last synced: 27 days ago
JSON representation
Provides a simple twig filter for expressing time difference in words.
- Host: GitHub
- URL: https://github.com/eschmar/time-ago-bundle
- Owner: eschmar
- License: mit
- Created: 2016-10-04T12:24:36.000Z (over 8 years ago)
- Default Branch: develop
- Last Pushed: 2022-12-22T15:47:10.000Z (about 2 years ago)
- Last Synced: 2024-11-14T23:29:17.770Z (about 2 months ago)
- Topics: symfony, symfony-bundle, twig, twig-extension
- Language: PHP
- Homepage:
- Size: 61.5 KB
- Stars: 16
- Watchers: 2
- Forks: 21
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TimeAgoBundle
Provides a simple twig filter for expressing time difference in words for Symfony.
Uses a range of +-7 days, after that, the actual date is returned.## Install
Composer (Packagist):
```sh
composer require eschmar/time-ago-bundle ^v2.0.0 # Symfony ^5.0
```or for older symfony versions:
```sh
composer require eschmar/time-ago-bundle ^v1.1.0 # Symfony ^4.x
composer require eschmar/time-ago-bundle ~v0.4.0 # Symfony ^2.8
composer require eschmar/time-ago-bundle ~v0.5.0 # Symfony ^3.4
```app/Appkernel.php (Symfony <4):
```php
new Eschmar\TimeAgoBundle\EschmarTimeAgoBundle(),
```## Usage
```twig
{{ date('now')|ago }}
{# just now #}{{ date('now').modify('-3 minutes')|ago }}
{# 3 minutes ago #}{{ date('now').modify('-3 months')|ago('r') }}
{# actual date in 'r' format #}{{ date('now').modify('+4 hours')|ago('r') }}
{# in 4 hours #}
```Change [default format](http://php.net/manual/en/function.date.php) in `config.yml`:
```yml
eschmar_time_ago:
format: 'Y-m-d H:i:s'
```# Translations available
* Belarusian
* Croatian
* Czech
* Danish
* Dutch
* English
* French
* Finnish
* German
* Hindi
* Hungarian
* Indonesian
* Italian
* Malay
* Norwegian
* Polish
* Portuguese (Brazil)
* Romanian
* Russian
* Slovenian
* Spanish
* Swedish
* Tagalog
* Turkish
* Ukranian
* Vietnamese# License
MIT License