wireRelativeTimeStr() function
Given a unix timestamp (or date string), returns a formatted string indicating the time relative to now
Examples: “1 day ago”, “30 seconds ago”, “just now”, etc.
This is the procedural version of $datetime->relativeTimeStr()
.
Based upon: http://www.php.net/manual/en/function.time.php#89415
Please note this method is and thus not intended to be called directly.
Internal usage
// basic internal usage
$string = wireRelativeTimeStr($ts);
// internal usage with all arguments
$string = wireRelativeTimeStr($ts, $abbreviate = false, bool $useTense = true);
Arguments
Name | Type(s) | Description |
---|---|---|
$ts | int string | Unix timestamp or date string |
$abbreviate (optional) | bool int array | Whether to use abbreviations for shorter strings.
|
$useTense (optional) | bool | Whether to append a tense like “ago” or “from now”, May be ok to disable in situations where all times are assumed in future or past. In abbreviate=1 (shortest) mode, this removes the leading "+" or "-" from the string. |
Return value
string
See Also
Functions methods and properties
API reference based on ProcessWire core version 3.0.251