MediaWiki
1.28.0
|
Library for creating, parsing, and converting 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. More... | |
__toString () | |
diff (ConvertibleTimestamp $relativeTo) | |
Calculate the difference between two ConvertibleTimestamp objects. More... | |
format ($format) | |
Format the timestamp in a given format. More... | |
getTimestamp ($style=TS_UNIX) | |
Get the timestamp represented by this object in a certain form. More... | |
getTimezone () | |
Get the timezone of this timestamp. More... | |
setTimestamp ($ts=false) | |
Set the timestamp to the specified time, or the current time if unspecified. More... | |
setTimezone ($timezone) | |
Set the timezone of this timestamp to the specified timezone. More... | |
Static Public Member Functions | |
static | convert ($style=TS_UNIX, $ts) |
Convert a timestamp string to a given format. More... | |
static | now ($style=TS_MW) |
Get the current time in the given format. More... | |
Public Attributes | |
DateTime | $timestamp |
The actual timestamp being wrapped (DateTime object). More... | |
Static Public Attributes | |
static | TS_MW |
Static Private Attributes | |
static | $formats |
Standard gmdate() formats for the different timestamp types. More... | |
Library for creating, parsing, and converting timestamps.
Based on the JS library that does the same thing.
Definition at line 31 of file ConvertibleTimestamp.php.
ConvertibleTimestamp::__construct | ( | $timestamp = false | ) |
Make a new timestamp and set it to the specified time, or the current time if unspecified.
bool | string | int | float | DateTime | $timestamp | Timestamp to set, or false for current time |
Definition at line 59 of file ConvertibleTimestamp.php.
References $timestamp, and setTimestamp().
ConvertibleTimestamp::__toString | ( | ) |
|
static |
Convert a timestamp string to a given format.
int | $style | Constant Output format for timestamp |
string | $ts | Timestamp |
Definition at line 171 of file ConvertibleTimestamp.php.
References $e.
Referenced by Database\decodeExpiry(), FileBackendStore\setFileCache(), ConvertibleTimestampTest\testConvert(), ConvertibleTimestampTest\testConvertInvalid(), and XMPValidate\validateDate().
ConvertibleTimestamp::diff | ( | ConvertibleTimestamp | $relativeTo | ) |
Calculate the difference between two ConvertibleTimestamp objects.
ConvertibleTimestamp | $relativeTo | Base time to calculate difference from |
Definition at line 233 of file ConvertibleTimestamp.php.
Referenced by Language\getHumanTimestampInternal(), and MWTimestamp\getRelativeTimestamp().
ConvertibleTimestamp::format | ( | $format | ) |
Format the timestamp in a given format.
string | $format | Pattern to format in |
Definition at line 266 of file ConvertibleTimestamp.php.
Referenced by Language\getHumanTimestampInternal(), and MWTimestamp\getTimezoneMessage().
ConvertibleTimestamp::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.
int | $style | Constant Output format for timestamp |
TimestampException |
Definition at line 200 of file ConvertibleTimestamp.php.
References $output, TS_MW, TS_POSTGRES, and TS_RFC2822.
Referenced by __toString(), and Language\getHumanTimestampInternal().
ConvertibleTimestamp::getTimezone | ( | ) |
Get the timezone of this timestamp.
Definition at line 256 of file ConvertibleTimestamp.php.
|
static |
Get the current time in the given format.
int | $style | Constant Output format for timestamp |
Definition at line 186 of file ConvertibleTimestamp.php.
ConvertibleTimestamp::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.
string | bool | $ts | Timestamp to store, or false for now |
TimestampException |
Definition at line 76 of file ConvertibleTimestamp.php.
Referenced by __construct().
ConvertibleTimestamp::setTimezone | ( | $timezone | ) |
Set the timezone of this timestamp to the specified timezone.
string | $timezone | Timezone to set |
TimestampException |
Definition at line 243 of file ConvertibleTimestamp.php.
References $e.
|
staticprivate |
Standard gmdate() formats for the different timestamp types.
Definition at line 35 of file ConvertibleTimestamp.php.
DateTime ConvertibleTimestamp::$timestamp |
The actual timestamp being wrapped (DateTime object).
Definition at line 51 of file ConvertibleTimestamp.php.
Referenced by __construct(), and MWTimestamp\getLocalInstance().
|
static |
Definition at line 37 of file ConvertibleTimestamp.php.
Referenced by getTimestamp().