# Get gateway Time through scritping

**URL:** <https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298>\
**Category:** Ignition\
**Created:** [February 18, 2022, 6:23am UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298 "2022-02-18T06:23:45Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 18, 2022, 6:23am UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298/1 "2022-02-18T06:23:45Z")

</div>

Hi,  
In Tag tree browser i am **getting system time**

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/e/be10dcd3b9fd1ec9823820d288eec291143e36e6.png)

But i want to capture the **gateway time through scripting**

how to get this ?

@paul-griffith any method to do it?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 18, 2022, 9:41am UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298/2 "2022-02-18T09:41:29Z")

</div>

`system.date.now()`

See [system.date - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/system.date).

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 18, 2022, 9:58am UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298/3 "2022-02-18T09:58:14Z")

</div>

no this is returning my system time only

we are using clinet timezoone

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/1/81a80e01a6a0ff8babbf542244cf933dfd46e1f8.png)

that why i am asking any alternative method capture the gateway time?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 18, 2022, 10:05am UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298/4 "2022-02-18T10:05:01Z")

</div>

```python
system.tag.readBlocking(['[System]Gateway/CurrentDateTime'])[0].value

```

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 18, 2022, 10:14am UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298/5 "2022-02-18T10:14:15Z")

</div>

**we are showing system time in this tag**  
system.tag.readBlocking([’[System]Gateway/CurrentDateTime’])[0].value`

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 18, 2022, 10:15am UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298/6 "2022-02-18T10:15:59Z")

</div>

this is system time  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/1/a194a07269c4c227292d755870bc273bb7f3a274.png)

this is gateway time

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/e/1e2113c0807fdc5f03f9c4257ee707ea28ef6d1b.png)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 18, 2022, 10:20am UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298/7 "2022-02-18T10:20:34Z")

</div>

That tag _is_ is gateway time. Is this more of a timezone question?

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 18, 2022, 10:35am UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298/8 "2022-02-18T10:35:44Z")

</div>

actually i am trying get the gateway time… that’s is the question

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 18, 2022, 10:52am UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298/9 "2022-02-18T10:52:13Z")

</div>

> [@JordanCClark](#):
>
> That tag _ **is** _ is gateway time.

Is it off because of a timezone difference, or are the minutes and seconds off too?

If it's a timezone thing, we can work around it. Otherwise you may have to call in to support.

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 18, 2022, 10:53am UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298/10 "2022-02-18T10:53:23Z")

</div>

Ok done

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 18, 2022, 4:53pm UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298/11 "2022-02-18T16:53:39Z")

</div>

> [@JordanCClark](#):
>
> That tag _is_ is gateway time. Is this more of a timezone question?

To be most explicit:  
That time has the _value_ of the gateway's time, but is _localized_ to the local timezone when you set the Vision timezone setting to Client, because in that case the Designer uses its own timezone information to _format the string_. The **actual value** of the tag is correct, it is just being localized for presentation.

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 18, 2022, 5:22pm UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298/12 "2022-02-18T17:22:22Z")

</div>

Is there any way to get gateway time now?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 18, 2022, 5:36pm UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298/13 "2022-02-18T17:36:03Z")

</div>

That _is the gateway time_. I promise. The complication is that `java.util.Date` objects represent (basically) epoch time - an always increasing count of (milli)seconds since some epoch:  
[https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Date.html](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Date.html)

If you don’t believe me, try this code in the script console:

```auto
from java.text import DateFormat
from com.inductiveautomation.ignition.client.gateway_interface import GatewayConnectionManager
from java.util import TimeZone

formatter = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG)
tz = GatewayConnectionManager.getInstance().getGatewayTimeZone()
formatter.setTimeZone(tz)
gwTime = system.tag.readBlocking(["[System]Gateway/CurrentDateTime"])[0].value
formatter.format(gwTime)
formatter.setTimeZone(TimeZone.getTimeZone("Europe/Paris"))
formatter.format(gwTime)

```

My gateway (and designer) are in America/Los Angeles, yet I get the following output:

```auto
>>> 
u'February 18, 2022 at 9:34:38 AM PST'
u'February 18, 2022 at 6:34:38 PM CET'

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 18, 2022, 5:43pm UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298/14 "2022-02-18T17:43:54Z")

</div>

You seem to misunderstand. Time in java is UTC. It is converted to local time zone when printed (or other string conversions). When you get any DateTime tag value, the UTC value is what travels through the network, not the string. If you need the string, you’ll want to use a message handler that will get and convert to string in the gateway, and return that string.

{ Edit: Paul beat me to it while distracted. So, what he said. }

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 18, 2022, 5:52pm UTC](https://forum.inductiveautomation.com/t/get-gateway-time-through-scritping/56298/15 "2022-02-18T17:52:58Z")

</div>

i am you believe you… i am just confused… thats why asked…when i just read the tag  
`gwTime = system.tag.readBlocking(["[System]Gateway/CurrentDateTime"])[0].value`

i have got sytem time only

I don’t know about the script to get the gateway time that why asked how to get the time through scripting

now i am getting gateway time thanks a alot
