# Convert EST to GMT using kibana script field

**URL:** <https://discuss.elastic.co/t/convert-est-to-gmt-using-kibana-script-field/268497>\
**Category:** Kibana\
**Created:** [March 26, 2021, 1:25pm UTC](https://discuss.elastic.co/t/convert-est-to-gmt-using-kibana-script-field/268497 "2021-03-26T13:25:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahulkothanath](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahulkothanath/32/99122_2.png) [@rahulkothanath](https://discuss.elastic.co/u/rahulkothanath)\
**Post date:** [March 26, 2021, 1:25pm UTC](https://discuss.elastic.co/t/convert-est-to-gmt-using-kibana-script-field/268497/1 "2021-03-26T13:25:54Z")

</div>

I have a field of date type(in EST) and I want to convert this to GMT before subtracting from another field using kibana script.  
below is the script field definition

> doc['re.pdz.end'].value - doc['test.P\_START\_TIME'].value.getMillis()

I want to convert doc['test.P\_START\_TIME'] into GMT to get proper millisecond difference since doc['re.pdz.end'] is GMT(UTC) already.

thanks for the help.

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [March 27, 2021, 12:34am UTC](https://discuss.elastic.co/t/convert-est-to-gmt-using-kibana-script-field/268497/2 "2021-03-27T00:34:18Z")

</div>

I think you'll want to look at the painless API documentation. It looks like there is a class available for an instance of a date that is timezone-aware. You'll want to make a date instance for each field value, and use compareTo to get the time difference. Then add the difference before the subtraction.

> **[Shared API for package java.time | Painless Scripting Language \[7.12\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-api-reference-shared-java-time.html#painless-api-reference-shared-ZonedDateTime)**

---

<div class="post-metadata">

**Author:** ![rahulkothanath](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahulkothanath/32/99122_2.png) [@rahulkothanath](https://discuss.elastic.co/u/rahulkothanath)\
**Post date:** [March 29, 2021, 12:20pm UTC](https://discuss.elastic.co/t/convert-est-to-gmt-using-kibana-script-field/268497/3 "2021-03-29T12:20:07Z")

</div>

Thank you for the way ahead. will check it out.

---

<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:** [April 26, 2021, 12:20pm UTC](https://discuss.elastic.co/t/convert-est-to-gmt-using-kibana-script-field/268497/4 "2021-04-26T12:20:38Z")

</div>

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