Timezones and Expressions

Any way to convert a Date to another, specifing a different timezone, using expressions?

Is the dateFormat expression not doing what you need?

Hi KathyApplebaum,
when i say “convert” i mean to change the internal timezone to another, changing even the time.
the dateFormat function only formats a date to show the internal timezone or not, but it does not accept a timezone to show the different time changing tz.

an example of what i need:
A = new date like “2014-07-07 09:37:00” with TimeZone “Europe/Rome”
print [i]changeTZ/i
should give
“2014-07-07 07:37:00 GMT”

this is for me the correct way to handle dates and times across clients and gateways placed in different world areas, is it?
thank you

You could try changing the client general section of the project properties:

Ah, I see now.

You can write a Python script to do this, and then call the script from the expression using runScript. I just checked in 7.7, and calling global scripts from an expression works great.

[edit] Posted just as Adam did. Sounds like his solution may be more what you want, anyway. :slight_smile:

General section of the project properties… this could be the answer! :thumb_left:
Thank you!

This there any way to change the Client timezone dynamically from the client?

If you are trying to correct a UTC time in the client, you could try this expression:

dateArithmetic({[.]LastPollTime}, toInt(dateFormat(now(),"Z")) / 100, "hour")

where [LastPollTime] is the UTC time that needs correcting.

(tested using Ignition 7.6.x)

1 Like