timespan()

timespan([$seconds = 1[, $time = ''[, $units = '']]])

Parameters:
  • $seconds (int) – Number of seconds
  • $time (string) – UNIX timestamp
  • $units (int) – Number of time units to display
Returns:

Formatted time difference

Return type:

string

Formats a UNIX timestamp so that is appears similar to this:

1 Year, 10 Months, 2 Weeks, 5 Days, 10 Hours, 16 Minutes

The first parameter must contain a UNIX timestamp. The second parameter must contain a timestamp that is greater that the first timestamp. The thirdparameter is optional and limits the number of time units to display.

If the second parameter empty, the current time will be used.

The most common purpose for this function is to show how much time has elapsed from some point in time in the past to now.

Example:

$post_date = '1079621429';
$now = time();
$units = 2;
echo timespan($post_date, $now, $units);

Note

The text generated by this function is found in the following language file: language/<your_lang>/date_lang.php

doc_CodeIgniter
2016-10-15 16:32:42
Comments
Leave a Comment

Please login to continue.