phpBB API Documentation
Class

phpbb\datetime

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

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 = '', boolean $force_absolute = false)

Formats the current date time into the specified format

string __toString()

Magic method to convert DateTime object to string

Details

at line 45
public __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
public string format(string $format = '', boolean $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
boolean $force_absolute Force output of a non relative date

Return Value

string Formatted date time

at line 128
public string __toString()

Magic method to convert DateTime object to string

Return Value

string Formatted date time, according to the users default settings.