# Is it possible to have milliseconds since 1970/01/01 indexed as 'date' type?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-have-milliseconds-since-1970-01-01-indexed-as-date-type/4023>\
**Category:** Elasticsearch\
**Created:** [March 3, 2011, 4:33pm UTC](https://discuss.elastic.co/t/is-it-possible-to-have-milliseconds-since-1970-01-01-indexed-as-date-type/4023 "2011-03-03T16:33:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jae\_Lee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jae_lee/32/3258_2.png) [@Jae\_Lee](https://discuss.elastic.co/u/Jae_Lee)\
**Post date:** [March 3, 2011, 4:33pm UTC](https://discuss.elastic.co/t/is-it-possible-to-have-milliseconds-since-1970-01-01-indexed-as-date-type/4023/1 "2011-03-03T16:33:47Z")

</div>

Hi,

I have a timestamp field that I want to index as 'date' type. It holds  
milliseconds since 1970/01/01.

Is it possible to get ES to index it as 'date'?

J

---

<div class="post-metadata">

**Author:** ![Administrator\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/administrator_2/32/3211_2.png) [@Administrator\_2](https://discuss.elastic.co/u/Administrator_2)\
**Post date:** [March 3, 2011, 5:53pm UTC](https://discuss.elastic.co/t/is-it-possible-to-have-milliseconds-since-1970-01-01-indexed-as-date-type/4023/2 "2011-03-03T17:53:22Z")

</div>

```
Why not store two fields?

On your end, you can easily turn those milliseconds since 1970/01/01

```

into a date/time value to store, and you can also store the number of  
milliseconds in a numeric field.

```
This way, you can index on both and perform the appropriate search

```

when needed for a small computational cost when inserting/updating.

```
	- Nick

```

-----Original Message-----  
From: jlee [[mailto:jlee119@gmail.com](mailto:jlee119@gmail.com)]  
Sent: Thursday, March 03, 2011 11:34 AM  
To: users  
Subject: Is it possible to have milliseconds since 1970/01/01 indexed as  
'date' type?

Hi,

I have a timestamp field that I want to index as 'date' type. It holds  
milliseconds since 1970/01/01.

Is it possible to get ES to index it as 'date'?

J

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 3, 2011, 6:01pm UTC](https://discuss.elastic.co/t/is-it-possible-to-have-milliseconds-since-1970-01-01-indexed-as-date-type/4023/3 "2011-03-03T18:01:21Z")

</div>

The date type already stores internally the date as UTC milliseconds since epoch. There is no option to provide the milliseconds directly, I guess the more interesting question here, if it was allowed, is how to handle time zone when providing just milliseconds. The date field mapper can get the milliseconds and make sure its in UTC, but that will be based on the local machine it is running on, and not (possibly) the client machine.

It might just be simpler to convert it to an ISO date format, and push that into elasticsearch.  
On Thursday, March 3, 2011 at 7:53 PM, Administrator wrote:

> Why not store two fields?
> 
> On your end, you can easily turn those milliseconds since 1970/01/01  
> into a date/time value to store, and you can also store the number of  
> milliseconds in a numeric field.
> 
> This way, you can index on both and perform the appropriate search  
> when needed for a small computational cost when inserting/updating.
> 
> - Nick
> 
> -----Original Message-----  
> From: jlee [[mailto:jlee119@gmail.com](mailto:jlee119@gmail.com)]  
> Sent: Thursday, March 03, 2011 11:34 AM  
> To: users  
> Subject: Is it possible to have milliseconds since 1970/01/01 indexed as  
> 'date' type?
> 
> Hi,
> 
> I have a timestamp field that I want to index as 'date' type. It holds  
> milliseconds since 1970/01/01.
> 
> Is it possible to get ES to index it as 'date'?
> 
> J

---

<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:10am UTC](https://discuss.elastic.co/t/is-it-possible-to-have-milliseconds-since-1970-01-01-indexed-as-date-type/4023/4 "2017-07-06T04:10:56Z")

</div>


