# Elastic Scripted Fields

**URL:** https://discuss.elastic.co/t/elastic-scripted-fields/208532
**Category:** Kibana
**Created:** [November 19, 2019, 3:00pm UTC](https://discuss.elastic.co/t/elastic-scripted-fields/208532 "2019-11-19T15:00:40Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![lou\_d](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lou_d/32/55759_2.png) [@lou\_d](https://discuss.elastic.co/u/lou_d)
#### Post date: [November 19, 2019, 3:00pm UTC](https://discuss.elastic.co/t/elastic-scripted-fields/208532/1 "2019-11-19T15:00:40Z")

</div>

Hi all,

I have a question regarding scripted fields.  
I have the below vertical bar which shows the number of requests for each hour of the day. To get the hour of the day I have the following scripted field - (doc['startTime'].value).getHour().

I have Kibana's timezone settings set to default (gets them from the browser).

I am at a UTC+2 timezone and when I change my regional settings I to UTC-5 and run the dashboard I expect all of the records to be with a 7 hour difference, e.g. the highest bar which is at 14 o'clock, should be at 07, however I get the absolutey same result.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/0/5001591642b40391bd12b0f2ef6e2d6ad3f36f7e.png)

Does anybody know why this is happening?

Cheers,  
Lou

---

<div class="post-metadata">

### Author: ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)
#### Post date: [November 19, 2019, 3:41pm UTC](https://discuss.elastic.co/t/elastic-scripted-fields/208532/2 "2019-11-19T15:41:35Z")

</div>

Hi @lou_d,

Scripted fields are executed on the Elasticsearch server and do not have access to the time zone of the browser. Judging from the [Elasticsearch docs](https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-datetime.html#_datetime_zone), UTC is assumed unless something else is specified in the script itself.

I don't see a way how you could pass the current Kibana timezone to the script unfortunately. By specifying the timezone in a Kibana advanced setting for all users and using the same timezone in the script you should at least get consistent results, even though the timezone isn't configurable per use anymore.

---

<div class="post-metadata">

### Author: ![lou\_d](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lou_d/32/55759_2.png) [@lou\_d](https://discuss.elastic.co/u/lou_d)
#### Post date: [November 20, 2019, 6:14am UTC](https://discuss.elastic.co/t/elastic-scripted-fields/208532/3 "2019-11-20T06:14:34Z")

</div>

Thanks @flash1293. I suspected that it had something to do with the execution time of the scripted field. Your suggestion sounds like the most reasonable approach.

Cheers,  
Lou

---

<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 18, 2019, 6:14am UTC](https://discuss.elastic.co/t/elastic-scripted-fields/208532/4 "2019-12-18T06:14:43Z")

</div>

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