MediaWiki REL1_31
|
Library for creating and parsing MW-style timestamps. More...
Public Member Functions | |
getHumanTimestamp (MWTimestamp $relativeTo=null, User $user=null, Language $lang=null) | |
Get the timestamp in a human-friendly relative format, e.g., "3 days ago". | |
getRelativeTimestamp (MWTimestamp $relativeTo=null, User $user=null, Language $lang=null, array $chosenIntervals=[]) | |
Generate a purely relative timestamp, i.e., represent the time elapsed between the given base timestamp and this object. | |
getTimezoneMessage () | |
Get the localized timezone message, if available. | |
offsetForUser (User $user) | |
Adjust the timestamp depending on the given user's preferences. | |
Static Public Member Functions | |
static | getInstance ( $ts=false) |
Get a timestamp instance in GMT. | |
static | getLocalInstance ( $ts=false) |
Get a timestamp instance in the server local timezone ($wgLocaltimezone) | |
Library for creating and parsing MW-style timestamps.
Based on the JS library that does the same thing.
Definition at line 32 of file MWTimestamp.php.
MWTimestamp::getHumanTimestamp | ( | MWTimestamp | $relativeTo = null, |
User | $user = null, | ||
Language | $lang = null ) |
Get the timestamp in a human-friendly relative format, e.g., "3 days ago".
Determine the difference between the timestamp and the current time, and generate a readable timestamp by returning "<N> <units> ago", where the largest possible unit is used.
MWTimestamp | null | $relativeTo | The base timestamp to compare to (defaults to now) |
User | null | $user | User the timestamp is being generated for (or null to use main context's user) |
Language | null | $lang | Language to use to make the human timestamp (or null to use main context's language) |
Definition at line 61 of file MWTimestamp.php.
References $lang, and RequestContext\getMain().
|
static |
Get a timestamp instance in GMT.
bool | string | $ts | Timestamp to set, or false for current time |
Definition at line 39 of file MWTimestamp.php.
|
static |
Get a timestamp instance in the server local timezone ($wgLocaltimezone)
bool | string | $ts | Timestamp to set, or false for current time |
Definition at line 204 of file MWTimestamp.php.
References $wgLocaltimezone.
Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\getTimezoneOptions().
MWTimestamp::getRelativeTimestamp | ( | MWTimestamp | $relativeTo = null, |
User | $user = null, | ||
Language | $lang = null, | ||
array | $chosenIntervals = [] ) |
Generate a purely relative timestamp, i.e., represent the time elapsed between the given base timestamp and this object.
MWTimestamp | $relativeTo | Relative base timestamp (defaults to now) |
User | $user | Use to use offset for |
Language | $lang | Language to use |
array | $chosenIntervals | Intervals to use to represent it |
Definition at line 147 of file MWTimestamp.php.
References $lang, diff, RequestContext\getMain(), and wfMessage().
MWTimestamp::getTimezoneMessage | ( | ) |
Get the localized timezone message, if available.
Premade translations are not shipped as format() may return whatever the system uses, localized or not, so translation must be done through wiki.
Definition at line 186 of file MWTimestamp.php.
References format, and wfMessage().
MWTimestamp::offsetForUser | ( | User | $user | ) |
Adjust the timestamp depending on the given user's preferences.
Definition at line 79 of file MWTimestamp.php.
References $e, and $wgLocalTZoffset.