◆ __construct()
Twig_Extensions_Extension_Date::__construct |
( |
TranslatorInterface |
$translator = null | ) |
|
◆ diff()
Twig_Extensions_Extension_Date::diff |
( |
Twig_Environment |
$env, |
|
|
|
$date, |
|
|
|
$now = null |
|
) |
| |
Filter for converting dates to a time ago string like Facebook and Twitter has.
- Parameters
-
Twig_Environment | $env | a Twig_Environment instance |
string | DateTime | $date | a string or DateTime object to convert |
string | DateTime | $now | A string or DateTime object to compare with. If none given, the current time will be used. |
- Returns
- string the converted time
Definition at line 56 of file Date.php.
References getPluralizedInterval(), and twig_date_converter().
63 $diff = $date->diff($now);
66 foreach (self::$units as $attribute => $unit) {
67 $count = $diff->$attribute;
getPluralizedInterval($count, $invert, $unit)
twig_date_converter(Twig_Environment $env, $date=null, $timezone=null)
Converts an input to a DateTime instance.
◆ getFilters()
Twig_Extensions_Extension_Date::getFilters |
( |
| ) |
|
◆ getName()
Twig_Extensions_Extension_Date::getName |
( |
| ) |
|
◆ getPluralizedInterval()
Twig_Extensions_Extension_Date::getPluralizedInterval |
( |
|
$count, |
|
|
|
$invert, |
|
|
|
$unit |
|
) |
| |
|
protected |
Definition at line 77 of file Date.php.
References $id, and array.
Referenced by diff().
79 if ($this->translator) {
80 $id = sprintf(
'diff.%s.%s', $invert ?
'in' :
'ago', $unit);
82 return $this->translator->transChoice(
$id, $count,
array(
'%count%' => $count),
'date');
89 return $invert ?
"in $count $unit" :
"$count $unit ago";
if(!array_key_exists('StateId', $_REQUEST)) $id
Create styles array
The data for the language used.
◆ $translator
Twig_Extensions_Extension_Date::$translator |
|
private |
◆ $units
Twig_Extensions_Extension_Date::$units |
|
static |
Initial value: 'y' => 'year',
'm' => 'month',
'd' => 'day',
'h' => 'hour',
'i' => 'minute',
's' => 'second',
)
Definition at line 18 of file Date.php.
The documentation for this class was generated from the following file:
- libs/composer/vendor/twig/extensions/lib/Twig/Extensions/Extension/Date.php