|
MediaWiki
REL1_20
|
Library for creating and parsing MW-style timestamps. More...
Public Member Functions | |
| __construct ($timestamp=false) | |
| Make a new timestamp and set it to the specified time, or the current time if unspecified. | |
| __toString () | |
| getHumanTimestamp () | |
| Get the timestamp in a human-friendly relative format, e.g., "3 days ago". | |
| getTimestamp ($style=TS_UNIX) | |
| Get the timestamp represented by this object in a certain form. | |
| setTimestamp ($ts=false) | |
| Set the timestamp to the specified time, or the current time if unspecified. | |
Private Attributes | |
| string DateTime | $timestamp |
| The actual timestamp being wrapped. | |
Static Private Attributes | |
| static | $formats |
| Standard gmdate() formats for the different timestamp types. | |
| static | $units |
| Different units for human readable timestamps. | |
Library for creating and parsing MW-style timestamps.
Based on the JS library that does the same thing.
Definition at line 31 of file Timestamp.php.
| MWTimestamp::__construct | ( | $ | timestamp = false | ) |
Make a new timestamp and set it to the specified time, or the current time if unspecified.
| $timestamp | bool|string Timestamp to set, or false for current time |
Definition at line 73 of file Timestamp.php.
Definition at line 223 of file Timestamp.php.
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.
Definition at line 196 of file Timestamp.php.
| MWTimestamp::getTimestamp | ( | $ | style = TS_UNIX | ) |
Get the timestamp represented by this object in a certain form.
Convert the internal timestamp to the specified format and then return it.
| $style | int Constant Output format for timestamp |
| TimestampException |
Definition at line 164 of file Timestamp.php.
| MWTimestamp::setTimestamp | ( | $ | ts = false | ) |
Set the timestamp to the specified time, or the current time if unspecified.
Parse the given timestamp into either a DateTime object or a Unix timestamp, and then store it.
| $ts | string|bool Timestamp to store, or false for now |
| TimestampException |
Definition at line 86 of file Timestamp.php.
MWTimestamp::$formats [static, private] |
array(
TS_UNIX => 'U',
TS_MW => 'YmdHis',
TS_DB => 'Y-m-d H:i:s',
TS_ISO_8601 => 'Y-m-d\TH:i:s\Z',
TS_ISO_8601_BASIC => 'Ymd\THis\Z',
TS_EXIF => 'Y:m:d H:i:s',
TS_RFC2822 => 'D, d M Y H:i:s',
TS_ORACLE => 'd-m-Y H:i:s.000000',
TS_POSTGRES => 'Y-m-d H:i:s',
TS_DB2 => 'Y-m-d H:i:s',
)
Standard gmdate() formats for the different timestamp types.
Definition at line 35 of file Timestamp.php.
string DateTime MWTimestamp::$timestamp [private] |
The actual timestamp being wrapped.
Either a DateTime object or a string with a Unix timestamp depending on PHP.
Definition at line 65 of file Timestamp.php.
MWTimestamp::$units [static, private] |
array(
"milliseconds" => 1,
"seconds" => 1000,
"minutes" => 60,
"hours" => 60,
"days" => 24
)
Different units for human readable timestamps.
Definition at line 52 of file Timestamp.php.