a Sensio Labs Product

The flexible, fast, and secure
template engine for PHP

Questions & Feedback

License

Twig documentation is licensed under the new BSD license.

The Intl Extension

The Intl extensions provides the localizeddate filter.

Installation

First, install the Extensions library. Next, add the extension to Twig:

1
$twig->addExtension(new Twig_Extensions_Extension_Intl());

localizeddate

Use the localizeddate filter to format dates into a localized string representating the date.

1
{{ post.published_at|localizeddate('medium', 'none', locale) }}

The localizeddate filter accepts strings (it must be in a format supported by the strtotime function), DateTime instances, or Unix timestamps.

Note

Internally, Twig uses the PHP IntlDateFormatter::create() function for the date.

Arguments

localizednumber

Use the localizednumber filter to format numbers into a localized string representating the number.

1
{{ product.quantity|localizednumber }}

Note

Internally, Twig uses the PHP NumberFormatter::create() function for the number.

Arguments

localizedcurrency

Use the localizedcurrency filter to format a currency value into a localized string.

1
{{ product.price|localizedcurrency('EUR') }}

Note

Internally, Twig uses the PHP NumberFormatter::create() function for the number.

Arguments

  • currency: The 3-letter ISO 4217 currency code indicating the currency to use.
  • locale: The locale used for the format. If NULL is given, Twig will use Locale::getDefault()
This website is powered by PHP and Twig. The Twig logo is © 2010-2012 Sensio Labs