# `date`
New in version 1.1: The timezone support has been added in Twig 1.1.
New in version 1.5: The default date format support has been added in Twig 1.5.
New in version 1.6.1: The default timezone support has been added in Twig 1.6.1.
New in version 1.11.0: The introduction of the false value for the timezone was introduced in Twig 1.11.0
The `date` filter formats a date to a given format:
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>{{ post.published_at|date("m/d/Y") }}
</pre></div></td></tr></table>
The format specifier is the same as supported by [date](http://www.php.net/date) [http://www.php.net/date],except when the filtered data is of type [DateInterval](http://www.php.net/DateInterval) [http://www.php.net/DateInterval], when the format must conform to[DateInterval::format](http://www.php.net/DateInterval.format) [http://www.php.net/DateInterval.format] instead.
The `date` filter accepts strings (it must be in a format supported by the[strtotime](http://www.php.net/strtotime) [http://www.php.net/strtotime] function), [DateTime](http://www.php.net/DateTime) [http://www.php.net/DateTime] instances, or [DateInterval](http://www.php.net/DateInterval) [http://www.php.net/DateInterval] instances. Forinstance, to display the current date, filter the word "now":
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>{{ "now"|date("m/d/Y") }}
</pre></div></td></tr></table>
To escape words and characters in the date format use `\\` in front of eachcharacter:
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>{{ post.published_at|date("F jS \\a\\t g:ia") }}
</pre></div></td></tr></table>
If the value passed to the `date` filter is `null`, it will return thecurrent date by default. If an empty string is desired instead of the currentdate, use a ternary operator:
~~~
{{ post.published_at is empty ? "" : post.published_at|date("m/d/Y") }}
~~~
If no format is provided, Twig will use the default one: `F j, Y H:i`. Thisdefault can be easily changed by calling the `setDateFormat()` method on the`core` extension instance. The first argument is the default format fordates and the second one is the default format for date intervals:
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2</pre></div></td><td class="code"><div class="highlight"><pre>$twig = new Twig_Environment($loader);
$twig->getExtension('core')->setDateFormat('d/m/Y', '%d days');
</pre></div></td></tr></table>
### Timezone
By default, the date is displayed by applying the default timezone (the onespecified in php.ini or declared in Twig -- see below), but you can overrideit by explicitly specifying a timezone:
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>{{ post.published_at|date("m/d/Y", "Europe/Paris") }}
</pre></div></td></tr></table>
If the date is already a DateTime object, and if you want to keep its currenttimezone, pass `false` as the timezone value:
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>{{ post.published_at|date("m/d/Y", false) }}
</pre></div></td></tr></table>
The default timezone can also be set globally by calling `setTimezone()`:
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2</pre></div></td><td class="code"><div class="highlight"><pre>$twig = new Twig_Environment($loader);
$twig->getExtension('core')->setTimezone('Europe/Paris');
</pre></div></td></tr></table>
### Arguments
- `format`: The date format
- `timezone`: The date timezone
- Twig
- Introduction
- Installation
- Twig for Template Designers
- Twig for Developers
- Extending Twig
- Twig Internals
- Deprecated Features
- Recipes
- Coding Standards
- Tags
- autoescape
- block
- do
- embed
- extends
- filter
- flush
- for
- from
- if
- import
- include
- macro
- sandbox
- set
- spaceless
- use
- verbatim
- Filters
- abs
- batch
- capitalize
- convert_encoding
- date
- date_modify
- default
- escape
- first
- format
- join
- json_encode
- keys
- last
- length
- lower
- merge
- nl2br
- number_format
- raw
- replace
- reverse
- round
- slice
- sort
- split
- striptags
- title
- trim
- upper
- url_encode
- Functions
- attribute
- block
- constant
- cycle
- date
- dump
- include
- max
- min
- parent
- random
- range
- source
- template_from_string
- Tests
- constant
- defined
- divisible by
- empty
- even
- iterable
- null
- odd
- same as