# Easy Chart - DB Pen - UNIX Timestamp - Local Timezone

**URL:** <https://forum.inductiveautomation.com/t/easy-chart-db-pen-unix-timestamp-local-timezone/23430>\
**Category:** Ignition\
**Created:** [March 18, 2019, 10:36pm UTC](https://forum.inductiveautomation.com/t/easy-chart-db-pen-unix-timestamp-local-timezone/23430 "2019-03-18T22:36:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dion.botha](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@dion.botha](https://forum.inductiveautomation.com/u/dion.botha)\
**Post date:** [March 18, 2019, 10:36pm UTC](https://forum.inductiveautomation.com/t/easy-chart-db-pen-unix-timestamp-local-timezone/23430/1 "2019-03-18T22:36:31Z")

</div>

Hi Guys,

I am logging values from an api call to our sql server database.

One of the values is a timestamp which represents the amount of seconds (not milliseconds!) since the UNIX epoch (January 1, 1970 00:00:00 UTC). This is the capture timestamp for the rest of the data.

Is there an easy way to use this in the easy chart such that the client see’s the data in their own timezone?

---

<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:** [March 18, 2019, 11:02pm UTC](https://forum.inductiveautomation.com/t/easy-chart-db-pen-unix-timestamp-local-timezone/23430/2 "2019-03-18T23:02:36Z")

</div>

Take that number, multiply by 1000L (long), and create a java.util.Date from it. It will show in the user’s local timezone. And it is the datatype you need to assign to Date properties throughout Ignition.

---

<div class="post-metadata">

**Author:** ![dion.botha](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@dion.botha](https://forum.inductiveautomation.com/u/dion.botha)\
**Post date:** [March 19, 2019, 2:32pm UTC](https://forum.inductiveautomation.com/t/easy-chart-db-pen-unix-timestamp-local-timezone/23430/3 "2019-03-19T14:32:07Z")

</div>

Hi Phil, are you suggesting I should do this when I grab the data and put it into my database or somehow do the conversion in the Easy Chart window? Not sure how to ‘create a java.util.Date from it’…

---

<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:** [March 19, 2019, 3:07pm UTC](https://forum.inductiveautomation.com/t/easy-chart-db-pen-unix-timestamp-local-timezone/23430/4 "2019-03-19T15:07:50Z")

</div>

You didn’t provide enough context on your data flow to be more specific, but my expectation was you were scripting your API calls. Given your unix epoch timestamp in a python numeric variable `ts`, you would convert it to an Ignition date like so:

```auto
import java.util.Date

def unix2date(ts):
    return java.util.Date(ts * 1000L)

```

In Ignition’s expression language, with a custom property `ts`, it would look like this:

```auto
toDate(toLong(1000) * {Root Container.SomeComponent.ts})

```

---

<div class="post-metadata">

**Author:** ![kjell](https://avatars.discourse-cdn.com/v4/letter/k/5daacb/32.png) [@kjell](https://forum.inductiveautomation.com/u/kjell)\
**Post date:** [October 16, 2019, 2:29pm UTC](https://forum.inductiveautomation.com/t/easy-chart-db-pen-unix-timestamp-local-timezone/23430/5 "2019-10-16T14:29:51Z")

</div>

Hi Phil,  
How to do the opposite way from date to unix epoch timestamp?  
My case:  
Classic chart Extension Funtions _configureChart_  
x = chart.plot.getDomainAxis()  
startX = x.minimumDate  
_convert to unix epoch timestamp? ----\>_ startX.minimumDate

_To be used in:_  
overlay = XYBoxAnnotation( **startX,** bottomY, endX, topY, stroke, outline, fill  
Thanks in advance  
-Kjell

---

<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:** [October 16, 2019, 3:27pm UTC](https://forum.inductiveautomation.com/t/easy-chart-db-pen-unix-timestamp-local-timezone/23430/6 "2019-10-16T15:27:41Z")

</div>

If you have a datetime object (java.util.Date) then the `.getTime()` method gives you the milliseconds of the unix epoch as a long. In jython, you can use `.time` as a shortcut property.

---

<div class="post-metadata">

**Author:** ![kjell](https://avatars.discourse-cdn.com/v4/letter/k/5daacb/32.png) [@kjell](https://forum.inductiveautomation.com/u/kjell)\
**Post date:** [October 17, 2019, 6:11am UTC](https://forum.inductiveautomation.com/t/easy-chart-db-pen-unix-timestamp-local-timezone/23430/7 "2019-10-17T06:11:57Z")

</div>

Ohh so “easy” thanks:slightly\_smiling\_face:! -Kjell

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [November 28, 2019, 4:32am UTC](https://forum.inductiveautomation.com/t/easy-chart-db-pen-unix-timestamp-local-timezone/23430/8 "2019-11-28T04:32:49Z")

</div>

How is ‘local timezone’ detected by Ignition?  
I am also reading in EPOC seconds from a PLC, and when i use the following expression to convert to date, it ends up being an hour forward of actual time.

```auto
toDate({[.]Value}*1000)

```

Note that i am in NZ and daylight savings is active.

---

<div class="post-metadata">

**Author:** ![harigobu.gb](https://avatars.discourse-cdn.com/v4/letter/h/b77776/32.png) [@harigobu.gb](https://forum.inductiveautomation.com/u/harigobu.gb)\
**Post date:** [February 6, 2021, 12:43pm UTC](https://forum.inductiveautomation.com/t/easy-chart-db-pen-unix-timestamp-local-timezone/23430/9 "2021-02-06T12:43:21Z")

</div>

# system.date.toMillis

([https://docs.inductiveautomation.com/display/DOC79/system.date.toMillis](https://docs.inductiveautomation.com/display/DOC79/system.date.toMillis))  
I saw this function in 7.9
