# Can I convert epoch time via data views to be readable?

**URL:** https://discuss.elastic.co/t/can-i-convert-epoch-time-via-data-views-to-be-readable/347677
**Category:** Kibana
**Created:** [November 22, 2023, 2:12am UTC](https://discuss.elastic.co/t/can-i-convert-epoch-time-via-data-views-to-be-readable/347677 "2023-11-22T02:12:34Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![geeboy1](https://avatars.discourse-cdn.com/v4/letter/g/f08c70/32.png) [@geeboy1](https://discuss.elastic.co/u/geeboy1)
#### Post date: [November 22, 2023, 2:12am UTC](https://discuss.elastic.co/t/can-i-convert-epoch-time-via-data-views-to-be-readable/347677/1 "2023-11-22T02:12:34Z")

</div>

good day,

my app log is in epoch time format (sample: 1700529701700), can I convert this using script in data views to be human readable format in discover menu? or any suggestion how to convert this?

i saw this in google, but I encountered "Cannot cast from [java.util.Date] to [void]. Verify that you have correctly set the runtime field type." error

cmd:  
return new Date(Long.parseLong(doc["TXN\_END.keyword"].value));

thank you very much

---

<div class="post-metadata">

### Author: ![geeboy1](https://avatars.discourse-cdn.com/v4/letter/g/f08c70/32.png) [@geeboy1](https://discuss.elastic.co/u/geeboy1)
#### Post date: [November 22, 2023, 6:22am UTC](https://discuss.elastic.co/t/can-i-convert-epoch-time-via-data-views-to-be-readable/347677/2 "2023-11-22T06:22:33Z")

</div>

or idea on how to put this epoch time format in mappings / template?

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [November 22, 2023, 6:28am UTC](https://discuss.elastic.co/t/can-i-convert-epoch-time-via-data-views-to-be-readable/347677/3 "2023-11-22T06:28:23Z")

</div>

Hi @geeboy1 welcome to the community!

Did you look at

> **[Date field type | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html)**

There are examples on that page

---

<div class="post-metadata">

### Author: ![geeboy1](https://avatars.discourse-cdn.com/v4/letter/g/f08c70/32.png) [@geeboy1](https://discuss.elastic.co/u/geeboy1)
#### Post date: [November 23, 2023, 1:44am UTC](https://discuss.elastic.co/t/can-i-convert-epoch-time-via-data-views-to-be-readable/347677/4 "2023-11-23T01:44:42Z")

</div>

hi @stephenb thank you 🙂

is below template correct?

data views:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/b/5b2fc7b1fdf14c9503934e023a52305bb2c9e3b3.png)

```auto
PUT _index_template/app1audit-template
{
  "index_patterns": ["app1audit*"],
  "template": {
    "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 0,
      "index.lifecycle.name": "180-days-default",      
      "index.lifecycle.rollover_alias": "app1audit-alias"    
    },
    "mappings": {
         "_source": {
            "enabled": true
      },
	    "properties" : {
        "TXN_START" : {
        "format" : "yyyy-MM-dd HH:mm:ss,SSS", <--- is this correct? or what format should I put here?
        "type" : "date"
       }
     }
   }
 }
}

```

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [November 23, 2023, 2:40am UTC](https://discuss.elastic.co/t/can-i-convert-epoch-time-via-data-views-to-be-readable/347677/5 "2023-11-23T02:40:29Z")

</div>

Perhaps this one

> `epoch_millis`  
> A formatter for the number of milliseconds since the epoch. Note, that this timestamp is subject to the limits of a Java Long.MIN\_VALUE and Long.MAX\_VALUE.

Sooo

`format" : "epoch_millis",`

Or as it says right in the beginning of the docs I referred you to.

> Date formats can be customised, but if no format is specified then it uses the default:

```
`"strict_date_optional_time||epoch_millis"`

```

So you could also just not specify a `format` or use that one....

---

<div class="post-metadata">

### Author: ![geeboy1](https://avatars.discourse-cdn.com/v4/letter/g/f08c70/32.png) [@geeboy1](https://discuss.elastic.co/u/geeboy1)
#### Post date: [November 23, 2023, 3:14am UTC](https://discuss.elastic.co/t/can-i-convert-epoch-time-via-data-views-to-be-readable/347677/6 "2023-11-23T03:14:07Z")

</div>

thanks a lot for the explanation @stephenb 🙂 this one works!!

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [November 23, 2023, 3:15am UTC](https://discuss.elastic.co/t/can-i-convert-epoch-time-via-data-views-to-be-readable/347677/7 "2023-11-23T03:15:45Z")

</div>

> [@geeboy1](#):
>
> _this_ one works!!

Which _this_ one 😉

Always good for others to show your solution...

---

<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: [December 21, 2023, 3:16am UTC](https://discuss.elastic.co/t/can-i-convert-epoch-time-via-data-views-to-be-readable/347677/8 "2023-12-21T03:16:09Z")

</div>

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