Download the PHP package smirik/php-datetime-ago without Composer

On this page you can find all versions of the php package smirik/php-datetime-ago. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-datetime-ago

php-datetime-ago

This library helps to format the date/time interval into text.

Examples

Condition Text
Now now
Less than an hour xx minutes ago
Between 1 and 2 hours 1 hour ago
Between 2 and 24 hours xx hours ago
Between 1 and 2 days 1 day ago
Between 2 and 6 days xx days ago
7 or more days ago xx weeks ago
30 or more days ago xx months ago
365 or more days ago xx years ago

Notice that not every translator supports weeks, months and years

Usage

DateTimeAgo class has public method get. It accepts 1 required argument (\DateTime object) and 1 optional (reference date. If it is null, current time is used).

Russian translation:

Customization

Date formatter for more than 6 days

This setup date in format 01.01.2001 22:52:12.

Custom translator

The DateTimeAgo constructor accept TextTranslator file as the first argument. By default EnglishTextTranslator is provided. You can add your custom translator to this constructor. Just make sure that your class implements Smirik\PHPDateTimeAgo\TextTranslator\TextTranslatorInterface. There is also standard way for translations based on pluralization procedure. The methods are already implemented for any language in AbstractTextTranslator class. English & Russian samples are already included in this package. You can also change the translator after creation:

Implementation

Tests

Most parts of the code are tested via phpspec. To run the tests clone the repository and run

Development workflow

Contribution

Any contribution is welcome.

Acknowledgements


All versions of php-datetime-ago with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package smirik/php-datetime-ago contains the following files

Loading the files please wait ....