Tag for Current Time in UTC?

Hello All,

First off, we are using Ignition version 7.7.4. I am trying to extract the different parts of a date for transmission into a database. Using the ‘dateExtract’ command, I was previously pulling the current time in with the ‘now’ tag, and getting the data I needed. The requirements have changed, so now I need to have this date/time info in UTC, instead of the gateway timezone (currently CST). There are other tags in the project that require the current gateway time, so I can’t change the ‘timezone behavior’ for the ‘now’ tag. Is there a system tag that has this info? Or is there an easy way to script a memory tag to convert the ‘now’ tag to UTC?

Here is an example as to how we are going to use this info:

Thanks for the help in advance!

Jake

Could you use a database function like GETDATE or CURRENT_TIMESTAMP in another query tag?

We added a lot of date/time manipulation functions in 7.9 that make this a lot easier to do inside Ignition - but on 7.7, I think the database is your best option.

Thank you for your reply, I ended up utilizing SQL to insert a UTC time stamp into the table when the data got processed.

It’s worth noting that java.util.Date objects are internally UTC and convert to the timezone of the program scope every time they are formatted into a string. And converted from the local timezone when constructed from hour/minute/second. These objects have a toGMTString() method that ignores the scope’s timezone. The .time property of these objects are always millisecond-resolution unix UTC long integers. Sending them in an RPC payload from client to gateway sends the UTC value, and will be correct even if client and gateway have different timezones. JDBC calls convert automatiically where possible (suitable column types). For example, using timestamp with timezone in PostgreSQL results in a column that always stores UTC (converting to/from the DB client connection TZ).
Run some experiments with a “SELECT CURRENT_TIMESTAMP;” queries with varying client and gateway timezones.