# Date format

**URL:** https://discuss.elastic.co/t/date-format/3202
**Category:** Elasticsearch
**Created:** [August 9, 2010, 2:58pm UTC](https://discuss.elastic.co/t/date-format/3202 "2010-08-09T14:58:25Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Andrew\_Degtiariov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrew_degtiariov/32/3223_2.png) [@Andrew\_Degtiariov](https://discuss.elastic.co/u/Andrew_Degtiariov)
#### Post date: [August 9, 2010, 2:58pm UTC](https://discuss.elastic.co/t/date-format/3202/1 "2010-08-09T14:58:25Z")

</div>

I have dates like this '2010-08-09T11:13:04+0300' and trying to add  
ones to mapping:  
...  
"created" : {  
"type" : "date",  
"format": "date\_time\_no\_millis"  
}  
...

But elasticsearch rejected index of documents with following error:  
IllegalArgumentException[Invalid format: "2010-08-09T11:13:04+0300" is  
malformed at "+0300"]

Which format I should use? I can normalize all dates to UTC (I don't  
need time zone in dates) but don't see proper format in documentation.

--  
Andrew Degtiariov  
DA-RIPE

---

<div class="post-metadata">

### Author: ![John\_Merrells](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@John\_Merrells](https://discuss.elastic.co/u/John_Merrells)
#### Post date: [August 9, 2010, 3:10pm UTC](https://discuss.elastic.co/t/date-format/3202/2 "2010-08-09T15:10:28Z")

</div>

I had a similar problem. I solved it by providing a mapping for my documents with a custom format for the date... e.g.

...  
"publication\_date" : {  
"index" : "not\_analyzed",  
"type" : "date",  
"format" : "yyyy/MM/dd HH:mm:ss Z"  
},  
...

John

On Aug 9, 2010, at 7:58 AM, Andrew Degtiariov wrote:

> I have dates like this '2010-08-09T11:13:04+0300' and trying to add  
> ones to mapping:  
> ...  
> "created" : {  
> "type" : "date",  
> "format": "date\_time\_no\_millis"  
> }  
> ...
> 
> But elasticsearch rejected index of documents with following error:  
> IllegalArgumentException[Invalid format: "2010-08-09T11:13:04+0300" is  
> malformed at "+0300"]
> 
> Which format I should use? I can normalize all dates to UTC (I don't  
> need time zone in dates) but don't see proper format in documentation.
> 
> --  
> Andrew Degtiariov  
> DA-RIPE

---

<div class="post-metadata">

### Author: ![John\_Merrells](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@John\_Merrells](https://discuss.elastic.co/u/John_Merrells)
#### Post date: [August 9, 2010, 3:12pm UTC](https://discuss.elastic.co/t/date-format/3202/3 "2010-08-09T15:12:22Z")

</div>

Date formatting...

[http://www.elasticsearch.com/docs/elasticsearch/mapping/date\_format/](http://www.elasticsearch.com/docs/elasticsearch/mapping/date_format/)

[http://joda-time.sourceforge.net/api-release/org/joda/time/format/DateTimeFormat.html](http://joda-time.sourceforge.net/api-release/org/joda/time/format/DateTimeFormat.html)

John

On Aug 9, 2010, at 7:58 AM, Andrew Degtiariov wrote:

> I have dates like this '2010-08-09T11:13:04+0300' and trying to add  
> ones to mapping:  
> ...  
> "created" : {  
> "type" : "date",  
> "format": "date\_time\_no\_millis"  
> }  
> ...
> 
> But elasticsearch rejected index of documents with following error:  
> IllegalArgumentException[Invalid format: "2010-08-09T11:13:04+0300" is  
> malformed at "+0300"]
> 
> Which format I should use? I can normalize all dates to UTC (I don't  
> need time zone in dates) but don't see proper format in documentation.
> 
> --  
> Andrew Degtiariov  
> DA-RIPE

---

<div class="post-metadata">

### Author: ![Andrew\_Degtiariov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrew_degtiariov/32/3223_2.png) [@Andrew\_Degtiariov](https://discuss.elastic.co/u/Andrew_Degtiariov)
#### Post date: [August 9, 2010, 3:29pm UTC](https://discuss.elastic.co/t/date-format/3202/4 "2010-08-09T15:29:34Z")

</div>

2010/8/9 John Merrells [merrells@gmail.com](mailto:merrells@gmail.com):

> I had a similar problem. I solved it by providing a mapping for my documents with a custom format for the date... e.g.
> 
> ...  
> "publication\_date" : {  
> "index" : "not\_analyzed",  
> "type" : "date",  
> "format" : "yyyy/MM/dd HH:mm:ss Z"  
> },  
> ...
> 
> John

Thank you!

Here my updated mapping for my object:  
...  
"created" : {  
"type" : "date",  
"index" : "not\_analyzed",  
"format" : "yyyy-MM-dd'T'HH:mm:ssZ"  
}  
...

--  
Andrew Degtiariov  
DA-RIPE

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 4:21am UTC](https://discuss.elastic.co/t/date-format/3202/5 "2017-07-06T04:21:01Z")

</div>


