# Enable Logstash to send date as epoch in milliseconds

**URL:** <https://discuss.elastic.co/t/enable-logstash-to-send-date-as-epoch-in-milliseconds/151211>\
**Category:** Logstash\
**Created:** [October 5, 2018, 1:05pm UTC](https://discuss.elastic.co/t/enable-logstash-to-send-date-as-epoch-in-milliseconds/151211 "2018-10-05T13:05:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![EricPSU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ericpsu/32/21110_2.png) [@EricPSU](https://discuss.elastic.co/u/EricPSU)\
**Post date:** [October 5, 2018, 1:05pm UTC](https://discuss.elastic.co/t/enable-logstash-to-send-date-as-epoch-in-milliseconds/151211/1 "2018-10-05T13:05:53Z")

</div>

I'm looking for the best way to have Logstash send dates as epoch in milliseconds. My Elasticsearch index has the field mapping below.

```
"createdDate": {
   "type": "date",
   "format": "epoch_millis"
}

```

If I post a document to the index via cURL, the date returns as epoch in milliseconds like this:

```
"createdDate": 1523302154204

```

If I post a document to the index via Logstash, the date returns as epoch in seconds like this:

```
"createdDate": 1523287754

```

I am able to use the Ruby filter below to force milliseconds, but I feel like there is a better solution.

```
if ([createdDate]) {
  ruby {    
    code => "event.set('createdDate', (event.get('createdDate').to_i * 1000));"
  }	
}
```

---

<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:** [November 2, 2018, 1:05pm UTC](https://discuss.elastic.co/t/enable-logstash-to-send-date-as-epoch-in-milliseconds/151211/2 "2018-11-02T13:05:56Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
