2017 © Pedro Peláez
 

library relative-time

Relative Time Calculator for PHP in 100 lines

image

bendahrooge/relative-time

Relative Time Calculator for PHP in 100 lines

  • Tuesday, December 15, 2015
  • by bendahrooge
  • Repository
  • 1 Watchers
  • 2 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

RelativeTime

Relative Time Calculator for PHP in 100 lines Relative time has been increasing popular amoung social media applications and micro-blog posts where the exact date content was posted isn't important or can be confusing to the end-user. The Library compares two Unix timestamps and outputs the elapsed time in minutes, hours, days, months or years., (*1)

Note: Relative time is different from elapsed time. Elapsed time has a focus on accuracy whereas relative time tries to be as human-readable as possible-even if it uses excessive rounding to do so. Relative time is not supposed to be accurate, therefore it should only be utilized in specific use cases., (*2)

Install via composer

Run this command in this command in your terminal to quickly install the package using composer., (*3)

composer require bendahrooge/relative-time

If you don't know what composer is (its pretty awesum) check out the documentation to install it., (*4)

Getting Relative Time

If you're using composer, the class will already be included by default on every script. You can start an instance of the class like this:, (*5)

$RelativeTime = new bendahrooge\RelativeTime;

The Library has 3 public functions avaible for use. All functions only support Unix time at the moment, if you wanna fix that and make a pull request that's cool., (*6)

$RelativeTime = new bendahrooge\RelativeTime;

$lastyear = $RelativeTime->since(1420000000); //This is Unix time for Wed Dec 31 2014 04:26:40
$afewdays = $RelativeTime->between(array(1449964800, 1450137600)); //About 1 day passing
$cantwait = $RelativeTime->until(1513296000); //Some time in the future

The Versions

15/12 2015

dev-master

9999999-dev https://github.com/bendahrooge/relative-time

Relative Time Calculator for PHP in 100 lines

  Sources   Download

MIT

relative time time since time until time between

15/12 2015

dev-non-class

dev-non-class https://github.com/bendahrooge/relative-time

Relative Time Calculator for PHP in 100 lines

  Sources   Download

MIT

relative time time since time until time between