Elasticsearch Date Format and Time Zone: What Changes and What Doesn't
How Elasticsearch parses, stores and converts dates across time zones, where the time_zone parameter applies, and when to keep the original text.
The short answer
Elasticsearch turns a date string into a single point in time, stored in UTC. The mapping's format setting controls how the string is parsed. Time zones come into play when you ingest, query or aggregate data, not inside the field itself. For most uses, the best approach is to send ISO 8601 timestamps with an explicit offset, let Elasticsearch store them as UTC, and apply a time zone only where people read or group the data.
The main benefit is that every document refers to one unambiguous instant, so sorting, range filters and comparisons across regions behave consistently. The main tradeoff is that the indexed value does not keep the original local clock time or the zone name. The source document still holds the string as sent, but searches and aggregations work on the converted instant.
A plain text field is the better choice in two cases. The first is when you must reproduce exactly what was entered, such as a local time recorded for compliance. The second is when the value is not an instant at all, such as a store's opening hours with no date attached.
What the format and time zone settings actually change
This is not a character-level text transformation. Nothing is reversed, mirrored or swapped for styled Unicode characters, and there is no bidirectional display effect. The mechanism is parsing and conversion. At index time, Elasticsearch matches the incoming string against the patterns listed in the field's format. It then converts the result to milliseconds since the Unix epoch in UTC, or nanoseconds for the date_nanos type, and stores that number for searching, sorting and aggregations.
- Indexed value: a UTC instant stored as a number, which queries and aggregations use.
- Source document: the original JSON string, returned unchanged in _source.
- Formatted output: strings rendered on request, for example through the fields or docvalue_fields options with a format, or as key_as_string in date aggregations.
- Display layer: clients such as Kibana may show the same instant in another zone. By default, Kibana uses the browser's time zone, and this can be changed in its advanced settings.
Two terms cause most of the confusion. In a mapping, "format" is a list of accepted input patterns, not a display style. And there is no per-field time zone setting in the mapping. A string without an offset is treated as UTC unless something earlier in the pipeline assigns a zone.
PUT my-index
{
"mappings": {
"properties": {
"event_time": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
}
}
}
}
The format shown above is the default. To accept several formats, separate them with a double pipe; Elasticsearch tries them in order. Custom patterns follow Java DateTimeFormatter syntax, which replaced Joda-style patterns in version 7.0. Three pattern details often cause errors. Lowercase y is the calendar year, while uppercase Y is the week-based year and can shift dates near New Year. Offsets need explicit letters such as XXX or Z. A literal T must be quoted as 'T'. The date field also accepts a locale parameter, which matters when parsing month or day names.
Where time zones apply
| Context | Parameter | Effect |
| Mapping | none | Input without an offset is interpreted as UTC |
| Ingest date processor | timezone | Zone assumed when a parsed string has no offset; the default is UTC |
| Range query | time_zone | Converts date values in the query to UTC before matching; does not change the value of now |
| Date histogram and date range aggregations | time_zone | Bucket boundaries such as calendar days follow that zone, including daylight saving shifts; keys stay UTC milliseconds, and key_as_string is formatted for the zone |
GET my-index/_search
{
"query": {
"range": {
"event_time": {
"gte": "2024-01-15T09:00:00",
"lt": "2024-01-15T17:00:00",
"time_zone": "America/New_York"
}
}
}
}
In this query, 09:00 New York time in January matches stored instants from 14:00 UTC, because New York is five hours behind UTC in winter. If a document containing "2024-01-15T09:00:00" with no offset was indexed without a zone, it was stored as 09:00 UTC. That is five hours earlier than the user meant, so the query above will not match it. This gap between how data was ingested and how it is queried is the most common source of time zone bugs. Named IANA zones such as America/New_York follow daylight saving changes; fixed offsets such as -05:00 do not.
GET my-index/_search
{
"size": 0,
"aggs": {
"per_day": {
"date_histogram": {
"field": "event_time",
"calendar_interval": "day",
"time_zone": "America/New_York"
}
}
}
}
PUT _ingest/pipeline/local-times
{
"processors": [
{
"date": {
"field": "local_time",
"target_field": "event_time",
"formats": ["yyyy-MM-dd HH:mm:ss"],
"timezone": "America/New_York"
}
}
]
}
The pipeline fixes the ingest-side problem described above. It reads a string without an offset as New York time and writes the correct UTC instant to event_time. If you omit target_field, the processor writes to @timestamp.
Will the result stay readable and usable after copying or sharing?
Copied values travel well only if they include an offset. A string rendered with a pattern like yyyy-MM-dd HH:mm drops the zone. Once it is pasted into another system or re-indexed, the receiver may read it as UTC or as its own local time. ISO 8601 with Z or an explicit offset, such as 2024-01-15T14:00:00Z or 2024-01-15T09:00:00-05:00, keeps its meaning across round trips.
Searching and editing also depend on the field type. A date field supports true range queries and chronological sorting. A date kept only as a keyword string sorts alphabetically. That works for fixed-width UTC ISO strings, but it breaks with mixed offsets or US-style values such as 01/15/2024.
Reading order is not affected, because date strings involve no bidirectional text or substituted glyphs. Readers may still find raw ISO strings harder to scan than a localized form like Jan 15, 2024, 9:00 AM EST. That localized formatting is usually best done in the application that displays the data. No evidence was available on how particular screen readers announce ISO 8601 timestamps, so test with the assistive technology your audience uses.
Keep a plain-text equivalent when the exact original wording matters. A common pattern is to store the converted date field for querying, plus keyword fields holding the original local string and its IANA zone ID.
Gaps to check before relying on this
- No version-specific tests were run for this review. The behavior described follows documented defaults, which have changed between major versions, notably the switch from Joda to Java patterns in 7.0.
- Check parameter names and defaults against the documentation for your Elasticsearch version.
- Display results in Kibana or in client libraries depend on deployment settings and were not verified here.