\AlphredDate

Provides text filters for date objects

This class should be cleaned up quite a bit, and it needs to be made pluggable so that it can be used by languages other than English. But, I think right now it is good enough to be released because it falls into "special sauce" rather than necessary functionality.

Summary

Methods
Properties
Constants
fuzzy_ago()
seconds_to_human_time()
ago()
convert_number_to_words()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
diff_a_date()
$legend_english
N/A

Properties

$legend_english

$legend_english : 

Type

Methods

fuzzy_ago()

fuzzy_ago(integer  $seconds, string  $dictionary = 'english') : string

Converts a time diff into a human readable approximation

Parameters

integer $seconds

a date represented in seconds since the unix epoch

string $dictionary

what language to use (currently unsupported and ignored)

Returns

string —

a fuzzy time

seconds_to_human_time()

seconds_to_human_time(integer  $seconds, boolean  $words = false, string  $type = 'string') : string|array

Converts seconds to a human readable string or an array

Parameters

integer $seconds

a number of seconds

boolean $words

whether or not the numbers should be numerals or words

string $type

either 'string' or 'array'

Returns

string|array —

a string or an array, depending on $type

ago()

ago(integer  $seconds, boolean  $words = false) : string

Explains how long ago something happened.

..

This also works with the future.

Parameters

integer $seconds

a number of seconds

boolean $words

whether or not to return numerals or the word-equivalent

Returns

string —

a string indicating a time in words

convert_number_to_words()

convert_number_to_words(integer  $number,   $dictionary = 'english') : string

Converts a number to words

Parameters

integer $number

a number

$dictionary

Returns

string —

the number, but, as words

diff_a_date()

diff_a_date(integer  $date1, integer  $date2) : array

Returns a slightly modified array of the difference between two dates

Parameters

integer $date1

a date in seconds

integer $date2

a date in seconds

Returns

array —

an array that represents the difference in granular units