# date\_range

Source: https://zotonic.com/docs/1496/date_range

URI: https://zotonic.com/id/1496

Language: en



Show a date range.

Filter to simplify displaying datetime ranges. When displaying a datetime range, the display of the dates and times often depends if the date parts of the datetimes are equal or not.

Take the following code:

```django
{{ [fromdate, todate]|date_range:[format_ne, sep, format_eq] }}
```

If the `dates` of fromdate and todate are equal then the output will be as if the following were written:

```django
{{ fromdate|date:format_ne }}{{ sep }}{{ todate|date:format_eq }}
```

However, if the dates are not equal then the output will be as if the following were written:

```django
{{ fromdate|date:format_ne }}{{ sep }}{{ todate|date:format_ne }}
```

Timezones
---------

Dates in Zotonic are stored in UTC. If a date is displayed then it is converted to the timezone of the current request context. This timezone can be one of the following, in order of preference:

- Preferred timezone set by the user
- Timezone of the user-agent
- Default timezone of the site
- Default timezone of the Zotonic server
- UTC

A specific timezone can be enforced by adding a third parameter to the date\_range-filter. For example, to display a date range in UTC:

```django
{{ [fromdate, todate]|date_range:[format_ne, sep, format_eq]:"UTC" }}
```

Instead of the timezone, the following arguments are also accepted:

- `true` set the timezone to UTC
- `false` leave the timezone as is
- `undefined` leave the timezone as is
- a resource id (integer), set the timezone according to the tz property of the resource

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1496?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1496?language=en>)
