Download the PHP package salernolabs/relative-time without Composer

On this page you can find all versions of the php package salernolabs/relative-time. 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 relative-time

salernolabs/relative-time

Latest Stable Version License Build Status

Library for building relative time strings in PHP.

Usage

Installation

First include this project with composer

composer require salernolabs/relative-time

Formatting Time

Then run the formatter on a DateTime object.

$formatter = new \SalernoLabs\RelativeTime\Formatter();
$relativeTime = $formatter->getRelativeTime(new \DateTime('-47 minutes'));
echo $relativeTime;

This would output '47 minutes ago'. The formatter will also go forward as well so if you put in '+47 minutes' it will say "47 mintues from now".

Examples of Time Reformatting

This library will also give short-hand conversational outputs for some values. For example:

Time Modification Output
-5 minutes just now
+5 minutes momentarily
-1 minute about a minute ago
+1 minute about a minute from now
-1 hour about an hour ago
+1 hour about an hour from now
-1 day yesterday
+1 day tomorrow

And actual numbers for other times, for example:

Time Modification Output
-45 seconds 45 seconds ago
-45 minutes 45 minutes ago
-7 hours 7 hours ago
-3 years 3 years ago

HTML5 Tags

You can easily wrap the output in an html5 time tag by using the getRelativeTimeTag function.

$formatter = new \SalernoLabs\RelativeTime\Formatter();
$relativeTime = $formatter->getRelativeTimeTag(new \DateTime('-47 minutes'));
echo $relativeTime;

This would output:

<time title="April 14th, 2017 - 4:14PM EDT">47 minutes ago</time>

Relative Time Clock

The relative time clock can give you a textual representation of a time of day.

$clock = new \SalernoLabs\RelativeTime\Clock();

$time = $clock
    ->setTime(new \DateTime('7:47'))
    ->getTime();

echo $time; // a quarter to eight o'clock

Examples of Relative Clock Output

Input Time Output
1:00 one o'clock
5:03 five o'clock,
2:07 almost ten after two o'clock,
3:10 ten after three o'clock
4:15 quarter after four o'clock
6:22 almost half past six o'clock
7:32 half past seven o'clock
8:44 almost a quarter to nine o'clock
9:45 a quarter to ten o'clock
11:55 almost twelve o'clock
12:00 twelve o'clock,
12:59 almost one o'clock
12:45 a quarter to one o'clock
12:43 almost a quarter to one o'clock

All versions of relative-time with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
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 salernolabs/relative-time contains the following files

Loading the files please wait ....