BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
Wikimedia\Timestamp\ConvertibleTimestamp Class Reference
Inheritance diagram for Wikimedia\Timestamp\ConvertibleTimestamp:

Public Member Functions

 __construct ($timestamp=false)
 
 setTimestamp ($ts=false)
 
 getTimestamp ($style=TS_UNIX)
 
 __toString ()
 
 diff (ConvertibleTimestamp $relativeTo)
 
 setTimezone ($timezone)
 
 getTimezone ()
 
 format ($format)
 

Static Public Member Functions

static convert ($style=TS_UNIX, $ts)
 
static now ($style=TS_MW)
 

Public Attributes

 $timestamp
 

Static Public Attributes

static TS_MW
 

Detailed Description

Library for creating, parsing, and converting timestamps.

Constructor & Destructor Documentation

Wikimedia\Timestamp\ConvertibleTimestamp::__construct (   $timestamp = false)

Make a new timestamp and set it to the specified time, or the current time if unspecified.

Parameters
bool | string | int | float | DateTime$timestampTimestamp to set, or false for current time

Member Function Documentation

Wikimedia\Timestamp\ConvertibleTimestamp::__toString ( )
Returns
string
static Wikimedia\Timestamp\ConvertibleTimestamp::convert (   $style = TS_UNIX,
  $ts 
)
static

Convert a timestamp string to a given format.

Parameters
int$styleConstant Output format for timestamp
string | int | bool$tsTimestamp
Returns
string|bool Formatted timestamp or false on failure
Wikimedia\Timestamp\ConvertibleTimestamp::diff ( ConvertibleTimestamp  $relativeTo)

Calculate the difference between two ConvertibleTimestamp objects.

Parameters
ConvertibleTimestamp$relativeToBase time to calculate difference from
Returns
DateInterval|bool The DateInterval object representing the difference between the two dates or false on failure
Wikimedia\Timestamp\ConvertibleTimestamp::format (   $format)

Format the timestamp in a given format.

Parameters
string$formatPattern to format in
Returns
string The formatted timestamp
Wikimedia\Timestamp\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.

Parameters
int$styleConstant Output format for timestamp
Exceptions
TimestampException
Returns
string The formatted timestamp
Wikimedia\Timestamp\ConvertibleTimestamp::getTimezone ( )

Get the timezone of this timestamp.

Returns
DateTimeZone The timezone
static Wikimedia\Timestamp\ConvertibleTimestamp::now (   $style = TS_MW)
static

Get the current time in the given format

Parameters
int$styleConstant Output format for timestamp
Returns
string
Wikimedia\Timestamp\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.

Parameters
string | bool$tsTimestamp to store, or false for now
Exceptions
TimestampException
Wikimedia\Timestamp\ConvertibleTimestamp::setTimezone (   $timezone)

Set the timezone of this timestamp to the specified timezone.

Parameters
string$timezoneTimezone to set
Exceptions
TimestampException

Member Data Documentation

Wikimedia\Timestamp\ConvertibleTimestamp::TS_MW
static
Initial value:
=> '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',
]

The documentation for this class was generated from the following file: