Coder Social home page Coder Social logo

time-ago-bundle's Introduction

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):

composer require eschmar/time-ago-bundle ^v2.0.0 # Symfony ^5.0

or for older symfony versions:

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):

new Eschmar\TimeAgoBundle\EschmarTimeAgoBundle(),

Usage

{{ 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 in config.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

time-ago-bundle's People

Contributors

058c37a272bed3464d47f0b01038a16a avatar anilkumarnandamuri avatar aylard avatar cherrykoda avatar delainewendling avatar eschmar avatar ghitu avatar hipposen avatar kietzmann avatar mertaytore avatar miyurusankalpa avatar norvinyecla avatar ocreaper avatar od3n avatar p0v1n0m avatar petk avatar pixelead0 avatar sarkkisjuha avatar sarokse avatar simonestefani avatar simonsolutions avatar supermansi avatar taufikherjanto avatar thewildhorse avatar voda avatar xirov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

time-ago-bundle's Issues

i18n

Right now, there are only translations for english. Would be nice to have more languages!

Add more translations

Right now we have translations for English and Swedish. Would be nice to support more!
Use Resources/translations/messages.en.yml as a reference and create a new file messages.XX.yml with XX being your locale.

TreeBuilder::root is deprecated

The "Symfony\Component\Config\Definition\Builder\TreeBuilder::root()" method called for the "eschmar_time_ago" configuration is deprecated since Symfony 4.3, pass the root name to the constructor instead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.