HumHub Documentation (unofficial)

CoreExtension extends AbstractExtension
in package

FinalYes

Table of Contents

Properties

$dateFormats  : mixed
$numberFormat  : mixed
$timezone  : mixed

Methods

convertDate()  : DateTime|DateTimeImmutable
Converts an input to a \DateTime instance.
formatDate()  : string
Formats a date.
formatNumber()  : string
Formats a number.
getDateFormat()  : array<string|int, mixed>
Gets the default format to be used by the date filter.
getFilters()  : array<string|int, TwigFilter>
Returns a list of filters to add to the existing list.
getFunctions()  : array<string|int, TwigFunction>
Returns a list of functions to add to the existing list.
getNodeVisitors()  : array<string|int, NodeVisitorInterface>
Returns the node visitor instances to add to the existing list.
getNumberFormat()  : array<string|int, mixed>
Get the default format used by the number_format filter.
getOperators()  : array<string|int, array<string|int, mixed>>
Returns a list of operators to add to the existing list.
getTests()  : array<string|int, TwigTest>
Returns a list of tests to add to the existing list.
getTimezone()  : DateTimeZone
Gets the default timezone to be used by the date filter.
getTokenParsers()  : array<string|int, TokenParserInterface>
Returns the token parser instances to add to the existing list.
setDateFormat()  : mixed
Sets the default format to be used by the date filter.
setNumberFormat()  : mixed
Sets the default format to be used by the number_format filter.
setTimezone()  : mixed
Sets the default timezone to be used by the date filter.

Properties

$dateFormats

private mixed $dateFormats = ['F j, Y H:i', '%d days']

Methods

convertDate()

Converts an input to a \DateTime instance.

public convertDate([DateTimeInterface|string|null $date = null ][, DateTimeZone|string|false|null $timezone = null ]) : DateTime|DateTimeImmutable

{% if date(user.created_at) < date('+2days') %} {# do something #} {% endif %}

Parameters
$date : DateTimeInterface|string|null = null

A date or null to use the current time

$timezone : DateTimeZone|string|false|null = null

The target timezone, null to use the default, false to leave unchanged

Return values
DateTime|DateTimeImmutable

formatDate()

Formats a date.

public formatDate(DateTimeInterface|DateInterval|string $date[, string|null $format = null ][, DateTimeZone|string|false|null $timezone = null ]) : string

{{ post.published_at|date("m/d/Y") }}

Parameters
$date : DateTimeInterface|DateInterval|string

A date

$format : string|null = null

The target format, null to use the default

$timezone : DateTimeZone|string|false|null = null

The target timezone, null to use the default, false to leave unchanged

Return values
string

formatNumber()

Formats a number.

public formatNumber(mixed $number[, int|null $decimal = null ][, string|null $decimalPoint = null ][, string|null $thousandSep = null ]) : string

All of the formatting options can be left null, in that case the defaults will be used. Supplying any of the parameters will override the defaults set in the environment object.

Parameters
$number : mixed

A float/int/string of the number to format

$decimal : int|null = null

the number of decimal points to display

$decimalPoint : string|null = null

the character(s) to use for the decimal point

$thousandSep : string|null = null

the character(s) to use for the thousands separator

Return values
string

getDateFormat()

Gets the default format to be used by the date filter.

public getDateFormat() : array<string|int, mixed>
Return values
array<string|int, mixed>

The default date format string and the default date interval format string

getFilters()

Returns a list of filters to add to the existing list.

public getFilters() : array<string|int, TwigFilter>
Return values
array<string|int, TwigFilter>

getNumberFormat()

Get the default format used by the number_format filter.

public getNumberFormat() : array<string|int, mixed>
Return values
array<string|int, mixed>

The arguments for number_format()

getOperators()

Returns a list of operators to add to the existing list.

public getOperators() : array<string|int, array<string|int, mixed>>
Return values
array<string|int, array<string|int, mixed>>

First array of unary operators, second array of binary operators

getTests()

Returns a list of tests to add to the existing list.

public getTests() : array<string|int, TwigTest>
Return values
array<string|int, TwigTest>

getTimezone()

Gets the default timezone to be used by the date filter.

public getTimezone() : DateTimeZone
Return values
DateTimeZone

The default timezone currently in use

setDateFormat()

Sets the default format to be used by the date filter.

public setDateFormat([string|null $format = null ][, string|null $dateIntervalFormat = null ]) : mixed
Parameters
$format : string|null = null

The default date format string

$dateIntervalFormat : string|null = null

The default date interval format string

setNumberFormat()

Sets the default format to be used by the number_format filter.

public setNumberFormat(int $decimal, string $decimalPoint, string $thousandSep) : mixed
Parameters
$decimal : int

the number of decimal places to use

$decimalPoint : string

the character(s) to use for the decimal point

$thousandSep : string

the character(s) to use for the thousands separator

setTimezone()

Sets the default timezone to be used by the date filter.

public setTimezone(DateTimeZone|string $timezone) : mixed
Parameters
$timezone : DateTimeZone|string

The default timezone string or a \DateTimeZone object


        
On this page

Search results