# Get timestamp based on timezone

**URL:** <https://forum.inductiveautomation.com/t/get-timestamp-based-on-timezone/105101>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 15, 2025, 10:09am UTC](https://forum.inductiveautomation.com/t/get-timestamp-based-on-timezone/105101 "2025-04-15T10:09:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaurav.amrutkar](https://avatars.discourse-cdn.com/v4/letter/g/e36b37/32.png) [@gaurav.amrutkar](https://forum.inductiveautomation.com/u/gaurav.amrutkar)\
**Post date:** [April 15, 2025, 10:09am UTC](https://forum.inductiveautomation.com/t/get-timestamp-based-on-timezone/105101/1 "2025-04-15T10:09:17Z")

</div>

Hi all,

In database, entry time is stored with column datatype as time with timezone. This db server is placed in UK region. So whenever new row inserts then date value stores as per UK time zone. We have requirement that this date should match with gateway server timezone. To do that we have written function to change time value into gateway timezone, But while converting that date into gateway specific timezone it shows wrong date time value. We have used java library functions to change date values but script is unable to return value in correct timezone.  
Is there any solution to 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:** [April 15, 2025, 10:18am UTC](https://forum.inductiveautomation.com/t/get-timestamp-based-on-timezone/105101/2 "2025-04-15T10:18:29Z")

</div>

The general recommendation is that timestamps are stored in UTC and then converted to desired timezone at the point of display.

You shouldn't need to use Java libraries as the [system.date | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-date) functions should have what you need.

Which module are you using? Vision, Perspective, Reporting? Add the tag to your question title.

---

<div class="post-metadata">

**Author:** ![gaurav.amrutkar](https://avatars.discourse-cdn.com/v4/letter/g/e36b37/32.png) [@gaurav.amrutkar](https://forum.inductiveautomation.com/u/gaurav.amrutkar)\
**Post date:** [April 15, 2025, 10:36am UTC](https://forum.inductiveautomation.com/t/get-timestamp-based-on-timezone/105101/3 "2025-04-15T10:36:11Z")

</div>

In perspective

---

<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:** [April 15, 2025, 10:44am UTC](https://forum.inductiveautomation.com/t/get-timestamp-based-on-timezone/105101/4 "2025-04-15T10:44:41Z")

</div>

Have you set the Perspective timezone in Project Properties? Normally you want Client Timezone.

---

<div class="post-metadata">

**Author:** ![gaurav.amrutkar](https://avatars.discourse-cdn.com/v4/letter/g/e36b37/32.png) [@gaurav.amrutkar](https://forum.inductiveautomation.com/u/gaurav.amrutkar)\
**Post date:** [April 15, 2025, 10:46am UTC](https://forum.inductiveautomation.com/t/get-timestamp-based-on-timezone/105101/5 "2025-04-15T10:46:37Z")

</div>

Yes, I set it to client timezone.

---

<div class="post-metadata">

**Author:** ![Arnaud\_Declerck](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/arnaud_declerck/32/44872_2.png) [@Arnaud\_Declerck](https://forum.inductiveautomation.com/u/Arnaud_Declerck)\
**Post date:** [April 15, 2025, 11:01am UTC](https://forum.inductiveautomation.com/t/get-timestamp-based-on-timezone/105101/6 "2025-04-15T11:01:40Z")

</div>

Are you sure that the column type in your database is storing the timestamp? Witch type of database are you using ?

---

<div class="post-metadata">

**Author:** ![gaurav.amrutkar](https://avatars.discourse-cdn.com/v4/letter/g/e36b37/32.png) [@gaurav.amrutkar](https://forum.inductiveautomation.com/u/gaurav.amrutkar)\
**Post date:** [April 15, 2025, 11:11am UTC](https://forum.inductiveautomation.com/t/get-timestamp-based-on-timezone/105101/7 "2025-04-15T11:11:56Z")

</div>

postgresql

---

<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:** [April 15, 2025, 12:04pm UTC](https://forum.inductiveautomation.com/t/get-timestamp-based-on-timezone/105101/8 "2025-04-15T12:04:03Z")

</div>

The `timestamp with timezone` column type in PostgreSQL (abbreviated as `timestamptz`) doesn't actually store the timezone, but uses the timezone information to ensure the underlying column data is correct for UTC. In other words, it works **exactly** the same as the `java.util.Date` object type in Ignition, and perfectly preserves the "instant in universal time" regardless of timezone settings in either the DB or the Ignition gateway. The timezone settings in Ignition for gateway and client then control how this is displayed and/or parsed from input.

If you have having difficulties with this, it is usually caused by failing to let Ignition and PostgreSQL handle those tasks. (Don't stringify your timestamps anywhere except for display.)
