class datetime extends DateTime

phpBB custom extensions to the PHP DateTime class This handles the relative formats phpBB employs

Constants

RELATIVE_WRAPPER

String used to wrap the date segment which should be replaced by today/tomorrow/yesterday

Properties

protected user $user
static protected array $format_cache

Methods

__construct(user $user, string $time = 'now', DateTimeZone $timezone = null)

Constructs a new instance of \phpbb\datetime, expanded to include an argument to inject the user context and modify the timezone to the users selected timezone if one is not set.

string
format(string $format = '', bool $force_absolute = false)

Formats the current date time into the specified format

string
__toString()

Magic method to convert DateTime object to string

static array
format_cache(string $format, user $user)

Pre-processes the specified date format

Details

at line 45
__construct(user $user, string $time = 'now', DateTimeZone $timezone = null)

Constructs a new instance of \phpbb\datetime, expanded to include an argument to inject the user context and modify the timezone to the users selected timezone if one is not set.

Parameters

user $user

object for context.

string $time

String in a format accepted by strtotime().

DateTimeZone $timezone

Time zone of the time.

at line 60
string format(string $format = '', bool $force_absolute = false)

Formats the current date time into the specified format

Parameters

string $format

Optional format to use for output, defaults to users chosen format

bool $force_absolute

Force output of a non relative date

Return Value

string

Formatted date time

at line 135
string __toString()

Magic method to convert DateTime object to string

Return Value

string

Formatted date time, according to the users default settings.

at line 147
static protected array format_cache(string $format, user $user)

Pre-processes the specified date format

Parameters

string $format

Output format

user $user

User object to use for localisation

Return Value

array

Processed date format