Skip to content
/ ago Public
forked from php-ago/ago

Converts given date into a nice readable format. Supports russian and english. Example will be '1 hour ago', '2 days ago', '1 second ago', 'Online' and so.

Notifications You must be signed in to change notification settings

awojtczyk/ago

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ago

Build Status Build Status Latest Stable Version Total Downloads License Minimum PHP Version

Date/time converter into "n time ago" format. Supports Russian and English languages.

Example

Default language is English. Optionally you can set the language in your application by calling set() method and passing a flag 'ru' or 'en';

Serhii\Ago\Lang::set('ru');

Usage

For outputting post publishing date or something else you can just pass the date to method ago(). It will count the interval between now and given date and returns needed format. Internally given date will be parsed by strtotime() PHP's function.

Serhii\Ago\Time::ago('now - 10 seconds'); // output: 10 seconds ago

Options

As the seconds argument ago method excepts array of options. Here is an example of passed options.

Time::ago('yesterday', ['no-suffix']); // output: 1 day

Available options

Option name Description
online Display "Online" if date interval within 60 seconds. After 60 seconds output will be the same as usually "x time ago" format.
no-suffix Remove suffix from date and have "5 minutes" instead of "5 minutes ago".
upcoming Without this option passed time will be subtracted from current time, but with this option it will take given time and subtract current time. It is useful if you need to display a counter for some date in future. Suffix will be also removed.

Quick Start

composer require serhii/ago

About

Converts given date into a nice readable format. Supports russian and english. Example will be '1 hour ago', '2 days ago', '1 second ago', 'Online' and so.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%