2017 © Pedro Peláez
 

library epoctools

Library to provide various epoc handling functions

image

hashbang/epoctools

Library to provide various epoc handling functions

  • Monday, May 12, 2014
  • by hashbang
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

EpocTools - PHP epoc manipulation

A simple library to provide various epoc handling functionality., (*1)

Installation

Installing into CodeIgniter

Download this repo and copy into your application directory., (*2)

Alternatively, install with Composer., (*3)

Functions

age - Helper function for humanize that returns the age of something

This function is used to calculate the age of an item relative to another time. See humanize for a full example list, (*4)

$this->EpocTools = new EpocTools();
$this->EpocTools->Age(strtotime('2011-01-01'), strtotime('2011-01-02')) // Reutns '1 day'
$this->EpocTools->Age(strtotime('2011-01-01 22:00'), strtotime('2011-01-02 23:00')) // Reutns '1 day, 1 hour'

date - Return the time at midnight of an epoc

When given any epoc style date this function sets the time of that epoc to midnight precicely., (*5)

$this->EpocTools = new EpocTools();
$this->EpocTools->date(time()); // Returns the epoc at midnight today
$this->EpocTools->date(strtotime('2011-01-01 04:32:21')); // Returns midnight on 01/01/2011

epocdateend - Return the last second of a given epoc date

In contrast to epocdate this function returns the last possible second of a given date., (*6)

$this->EpocTools = new EpocTools();
$this->EpocTools->dateend(time()); // Returns the last possible second of todays date
$this->EpocTools->dateend(strtotime('2011-01-01 04:32:21')); // Returns 23:59:59 on 01/01/2011

getstamp - The inverse of date()

This function takes a given string and converts it into a date using the template provided. This is in contrast to the default PHP Date() function which does the opposit., (*7)

$this->EpocTools = new EpocTools();
$this->EpocTools->getstamp('d/m/Y H:M','02/07/1983 1035'); // Returns unix timestamp 425952900

humanize - Returns a sequence of seconds in human format

This function can be used to return how far an event occurs in the past or future relative to the current time, (*8)

$this->EpocTools = new EpocTools();
$this->EpocTools->Humanize(time() - 60); // Returns '60 seconds ago'
$this->EpocTools->Humanize(time() - 5400); // Returns '1 hour, 30 minutes ago'
$this->EpocTools->Humanize(time() - 72576000); // Returns '2 weeks ago'

A vareity of options can be specified including how many time scales should be selected (i.e. how specific) for example '2 weeks, 1 hour' would have two blocks, '2 weeks, 1 hour, 38 minutes, 42 seconds' would have four., (*9)

shorthand - Return the number of seconds from a human readable time shorthand

This function returns the number of seconds determined from a shorthand time string., (*10)

$this->EpocTools = new EpocTools();
$this->EpocTools->Shorthand('1h') // Returns 3600 (1 hour - 60*60)
$this->EpocTools->Shorthand('1h30m') // Returns 5400 (1 hour 30 minutes - 60*60 + 30*60)
$this->EpocTools->Shorthand('2w') // Returns 72576000 (2 weeks - 7*24*60*60*60*2)

The Versions

12/05 2014

dev-master

9999999-dev https://github.com/hash-bang/EpocTools

Library to provide various epoc handling functions

  Sources   Download

MIT

The Requires

  • php >=5.0.0

 

time

12/05 2014

v1.1.3

1.1.3.0 https://github.com/hash-bang/EpocTools

Library to provide various epoc handling functions

  Sources   Download

MIT

The Requires

  • php >=5.0.0

 

time

12/05 2014

v1.1.2

1.1.2.0 https://github.com/hash-bang/EpocTools

Library to provide various epoc handling functions

  Sources   Download

MIT

The Requires

  • php >=5.0.0

 

time

10/04 2014

v1.1.1

1.1.1.0 https://github.com/hash-bang/EpocTools

Library to provide various epoc handling functions

  Sources   Download

MIT

The Requires

  • php >=5.0.0

 

time

10/04 2014

v1.1.0

1.1.0.0 https://github.com/hash-bang/EpocTools

Library to provide various epoc handling functions

  Sources   Download

MIT

The Requires

  • php >=5.0.0

 

time

21/03 2014

v1.0.0

1.0.0.0 https://github.com/hash-bang/Time

Library to provide various time functions

  Sources   Download

MIT

The Requires

  • php >=5.0.0

 

time