2017 © Pedro Peláez
 

library timegap

image

khandieyea/timegap

  • Monday, March 17, 2014
  • by khandieyea
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,199 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

Timegap

Build Status, (*1)

Change Log - 26/7/13 - Fixed typo in read me (thanks @davemfletcher), (*2)

WHY?

Timegap as a time-passed or time-until helper that only shows relevant information. If something (such as a birthday) is 6 months away, do we really care about the seconds or minutes? I basically got sick of seeing things like:, (*3)

Your next appointment is in 1 year, 3 months, 2 weeks, 4 days, 11 hours, 21 minutes, 11 seconds, (*4)

That's pretty over exagerated, but you get the idea. Timegap is an attempt at solving this., (*5)

Composer

https://packagist.org/packages/khandieyea/timegap, (*6)

A usage example

Let's say your birthday is in 10 days:, (*7)

$gap = Timegap::createThen('a datetime stamp or unix tick that is 10 days from now');

echo "Your birthday is in: ";
echo $gap->output('weeks, days, hours, minutes, seconds', 2);

At first, this will result in, (*8)

Your birthday is in: 1 week, 4 days, (*9)

As the gap closes say 6 days away, the 'weeks' will disappear and we will see hours, (*10)

Your birthday is in: 6 days, 4 hours, (*11)

Singular/plural words are taken care of, when your birthday is just over a day away, (*12)

Your birthday is in: 1 day, 8 hours, (*13)

As we get closer and there's less than 1 day to go, again day drops off and minutes appear, (*14)

Your birthday is in: 4 hours, 46 minutes, (*15)

And again, when under an hour to go, (*16)

Your birthday is in: 24 minutes, 11 seconds, (*17)

Dumb stuff you can do

$gap = new Timegap::createThen('a datetime stamp or tick that is 11 hours away');

echo "Your taxi will arrive in: ";
echo $gap->output('hours, minutes, seconds');
echo "<br />That's in precisely ";
echo $gap->output('seconds');

Would give you something like, (*18)

Your taxi will arrive in: 10 hours, 59 minutes, 58 seconds, (*19)

That's in precisely 39598 seconds, (*20)

The Versions

17/03 2014

dev-master

9999999-dev

  Sources   Download

The Requires

  • php >=5.2.0

 

17/03 2014

v1.0.0

1.0.0.0

  Sources   Download

The Requires

  • php >=5.2.0