# Why \_timestamp field is not returned with the format that we have set in the mapping?

**URL:** <https://discuss.elastic.co/t/why--timestamp-field-is-not-returned-with-the-format-that-we-have-set-in-the-mapping/22879>\
**Category:** Elasticsearch\
**Created:** [March 25, 2015, 4:47am UTC](https://discuss.elastic.co/t/why--timestamp-field-is-not-returned-with-the-format-that-we-have-set-in-the-mapping/22879 "2015-03-25T04:47:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lee\_Chuen\_Ooi](https://avatars.discourse-cdn.com/v4/letter/l/91b2a8/32.png) [@Lee\_Chuen\_Ooi](https://discuss.elastic.co/u/Lee_Chuen_Ooi)\
**Post date:** [March 25, 2015, 4:47am UTC](https://discuss.elastic.co/t/why--timestamp-field-is-not-returned-with-the-format-that-we-have-set-in-the-mapping/22879/1 "2015-03-25T04:47:02Z")

</div>

Hi,  
I want to make use of the \_timestamp field to keep track the last indexed  
datetime of an doc in ElasticSearch.  
I have set the mapping as below:

```
  "mappings": {
     "_default_": {
        "_timestamp": {
           "enabled": true,
           "store": true,
           "format": "yyyy-MM-dd'T'HH:mm:ss.SSS"
        }

```

I have mentioned the \_timestamp field with date format (as red font  
highlighted). However, when I query the doc, the \_timestamp field is still  
showing as the unix format as below:

```
        "fields": {
           "_timestamp": 1427177681930
        }

```

_Question_

1. I am using ElasticSearch version 1.32. Is this a bug?
2. How can we get the \_timestamp field with the correct format that we  
want? How to convert the \_timestamp to a readable format? I use Sense to  
query.

Thanks.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/68f60356-f3de-406b-890c-338e5cc31a64%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/68f60356-f3de-406b-890c-338e5cc31a64%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [March 25, 2015, 6:38am UTC](https://discuss.elastic.co/t/why--timestamp-field-is-not-returned-with-the-format-that-we-have-set-in-the-mapping/22879/2 "2015-03-25T06:38:18Z")

</div>

ES stores timestamps as unix epoch under the hood, however it will  
translate that to UTC when you request it.

On 25 March 2015 at 15:47, Lee Chuen Ooi [leechuen@gmail.com](mailto:leechuen@gmail.com) wrote:

> Hi,  
> I want to make use of the \_timestamp field to keep track the last indexed  
> datetime of an doc in Elasticsearch.  
> I have set the mapping as below:
> 
> ```
> "mappings": {
> "_default_": {
> "_timestamp": {
> "enabled": true,
> "store": true,
> "format": "yyyy-MM-dd'T'HH:mm:ss.SSS"
> }
> 
> ```
> 
> I have mentioned the \_timestamp field with date format (as red font  
> highlighted). However, when I query the doc, the \_timestamp field is still  
> showing as the unix format as below:
> 
> ```
> "fields": {
> "_timestamp": 1427177681930
> }
> 
> ```
> 
> _Question_
> 
> 1. I am using Elasticsearch version 1.32. Is this a bug?
> 2. How can we get the \_timestamp field with the correct format that we  
> want? How to convert the \_timestamp to a readable format? I use Sense to  
> query.
> 
> Thanks.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/68f60356-f3de-406b-890c-338e5cc31a64%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/68f60356-f3de-406b-890c-338e5cc31a64%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/68f60356-f3de-406b-890c-338e5cc31a64%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/68f60356-f3de-406b-890c-338e5cc31a64%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAEYi1X9obvrsEqmk%3DOeqOkFtEQ9JedTMJ-8mUTA69id9Z5jtmw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAEYi1X9obvrsEqmk%3DOeqOkFtEQ9JedTMJ-8mUTA69id9Z5jtmw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Lee\_Chuen\_Ooi](https://avatars.discourse-cdn.com/v4/letter/l/91b2a8/32.png) [@Lee\_Chuen\_Ooi](https://discuss.elastic.co/u/Lee_Chuen_Ooi)\
**Post date:** [March 25, 2015, 8:21am UTC](https://discuss.elastic.co/t/why--timestamp-field-is-not-returned-with-the-format-that-we-have-set-in-the-mapping/22879/3 "2015-03-25T08:21:07Z")

</div>

Hi Mark,  
Here is my query. The result returned is not in UTC, still in unix epoch.  
Do you know why?

_Query run in Sense:_  
GET \_search?fields=\_timestamp,\_source  
{  
"query": { "match\_all": {} }  
}

_Result:_  
"fields": {  
"\_timestamp": 1427177681930  
}

On Wednesday, March 25, 2015 at 2:39:06 PM UTC+8, Mark Walkom wrote:

> ES stores timestamps as unix epoch under the hood, however it will  
> translate that to UTC when you request it.
> 
> On 25 March 2015 at 15:47, Lee Chuen Ooi \<[leec...@gmail.com](mailto:leec...@gmail.com) \<javascript:\>\>  
> wrote:
> 
> > Hi,  
> > I want to make use of the \_timestamp field to keep track the last indexed  
> > datetime of an doc in Elasticsearch.  
> > I have set the mapping as below:
> > 
> > ```
> > "mappings": {
> > "_default_": {
> > "_timestamp": {
> > "enabled": true,
> > "store": true,
> > "format": "yyyy-MM-dd'T'HH:mm:ss.SSS"
> > }
> > 
> > ```
> > 
> > I have mentioned the \_timestamp field with date format (as red font  
> > highlighted). However, when I query the doc, the \_timestamp field is still  
> > showing as the unix format as below:
> > 
> > ```
> > "fields": {
> > "_timestamp": 1427177681930
> > }
> > 
> > ```
> > 
> > _Question_
> > 
> > 1. I am using Elasticsearch version 1.32. Is this a bug?
> > 2. How can we get the \_timestamp field with the correct format that we  
> > want? How to convert the \_timestamp to a readable format? I use Sense to  
> > query.
> > 
> > Thanks.
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/68f60356-f3de-406b-890c-338e5cc31a64%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/68f60356-f3de-406b-890c-338e5cc31a64%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/68f60356-f3de-406b-890c-338e5cc31a64%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/68f60356-f3de-406b-890c-338e5cc31a64%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8dc8a632-b7a6-499c-a299-e0abb2d2055d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8dc8a632-b7a6-499c-a299-e0abb2d2055d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:24am UTC](https://discuss.elastic.co/t/why--timestamp-field-is-not-returned-with-the-format-that-we-have-set-in-the-mapping/22879/4 "2017-07-06T00:24:10Z")

</div>


