How to set Timezone in reporting jython for data

For a specific subset of regular reports, I need the scripting to kick out data in a fixed offset time zone. (UTC would be fine, UTC -x would be marginally better.)

The gateway is correctly configured to use daylight savings so the system works as needed for display & local control interaction. That also works for the majority of reporting.

I've tried pulling the date and trying to return it with system.date.format(foo,"yyyy-MM-dd HH:mm:ss X="-0700"), but that just shows the existing gateway timezone and then my input.

Similar with other variations of single quotes, no quotes, -7, and substituting Z instead of X based on the simple date format. I'm sure I am missing something silly, but I cannot find how to get the system to report data in my desired timezone.

This is just to display in a report & kick to Excel format. If it can simply show the data in UTC, I can manually manipulate hours if necessary.

Since this is within a dataset, I also will need to then append it to a new data column. I think I have correctly set that up:

from java.util import Date && system.dataset.addColumn(PDS,foo,"NewTime",Date)

Thank you.

java.util.date is fundamentally UTC under the hood. If you need a specific time zone, use java.time.ZonedDateTime

from java.time import ZoneId
from java.time.format import DateTimeFormatter

# java.util.date
now = system.date.now()

# java.time.ZonedDateTime
localTime = now.toInstant().atZone(ZoneId.of('US/Pacific'))

# formatted string
formatter = DateTimeFormatter.ofPattern('yyyy-MM-dd HH:mm:ss')
formattedTime = localTime.format(formatter)

print 'now: {} {}'.format(now, type(now))
print 'newTime: {} {}'.format(localTime, type(localTime))
print 'formattedTime: {} {}'.format(formattedTime, type(formattedTime))

Output:

now: Tue Oct 27 12:24:38 EDT 2026 <type 'java.util.Date'>
newTime: 2026-10-27T09:24:38.683-07:00[US/Pacific] <type 'java.time.ZonedDateTime'>
formattedTime: 2026-10-27 09:24:38 <type 'unicode'>
>>> 

Perfect, thank you Jordan!

One of these years I'll figure out if I need to be learning java or python... and then still fail as I'm at best a PLC person who ocassionally hits SCADA.

Both. Jython is python syntax with Java libraries.