Documentation

Twig_Extensions_Extension_Date extends Twig_Extension
in package

Tags
author

Robin van der Vleuten robinvdvleuten@gmail.com

Table of Contents

$units  : mixed
$translator  : TranslatorInterface
__construct()  : mixed
diff()  : string
Filter for converting dates to a time ago string like Facebook and Twitter has.
getFilters()  : mixed
{@inheritdoc}
getFunctions()  : array<string|int, TwigFunction>
Returns a list of functions to add to the existing list.
getName()  : mixed
{@inheritdoc}
getNodeVisitors()  : array<string|int, NodeVisitorInterface>
Returns the node visitor instances to add to the existing list.
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.
getTokenParsers()  : array<string|int, TokenParserInterface>
Returns the token parser instances to add to the existing list.
getPluralizedInterval()  : mixed

Properties

$units

public static mixed $units = array('y' => 'year', 'm' => 'month', 'd' => 'day', 'h' => 'hour', 'i' => 'minute', 's' => 'second')

$translator

private TranslatorInterface $translator

Methods

diff()

Filter for converting dates to a time ago string like Facebook and Twitter has.

public diff(Twig_Environment $env, string|DateTime $date[, string|DateTime $now = null ]) : string
Parameters
$env : Twig_Environment

a Twig_Environment instance

$date : string|DateTime

a string or DateTime object to convert

$now : string|DateTime = null

A string or DateTime object to compare with. If none given, the current time will be used.

Return values
string

the converted time

getFilters()

{@inheritdoc}

public getFilters() : mixed
Return values
mixed

getName()

{@inheritdoc}

public getName() : mixed
Return values
mixed

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>

getPluralizedInterval()

protected getPluralizedInterval(mixed $count, mixed $invert, mixed $unit) : mixed
Parameters
$count : mixed
$invert : mixed
$unit : mixed
Return values
mixed

Search results