# Scheduled Gateway Script operation during Daylight Savings time shift

**URL:** <https://forum.inductiveautomation.com/t/scheduled-gateway-script-operation-during-daylight-savings-time-shift/111079>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [September 29, 2025, 10:19pm UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-script-operation-during-daylight-savings-time-shift/111079 "2025-09-29T22:19:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![SWoollett](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@SWoollett](https://forum.inductiveautomation.com/u/SWoollett)\
**Post date:** [September 29, 2025, 10:19pm UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-script-operation-during-daylight-savings-time-shift/111079/1 "2025-09-29T22:19:04Z")

</div>

I have a gateway script scheduled to execute 1 minute past the hour, every hour which syncs the PLC clocks with the gateway clock.

In September the clocks jump forward an hour from 2AM to 3AM

In the gateway logs I have observed is the following:

01:01 - Script executes, no update to clocks preformed  
03:01 - Script executes, no update to clocks preformed  
04:01 - Script executes, PLC clocks updated

My expectation is that when the system time jumps to 3AM and the script is then executed at 3:01AM the times should be updated then, However this doesn’t appear to be the case.

I use system.date.now() to retrieve the gateway time in my script, is there anything else I should be calling to ensure the system time I retrieve is correct?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 29, 2025, 10:25pm UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-script-operation-during-daylight-savings-time-shift/111079/2 "2025-09-29T22:25:36Z")

</div>

> [@SWoollett](#):
>
> I use system.date.now() to retrieve the gateway time in my script

What do you do after this? How do you pick it apart and then sync the time to the PLC clock?

---

<div class="post-metadata">

**Author:** ![SWoollett](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@SWoollett](https://forum.inductiveautomation.com/u/SWoollett)\
**Post date:** [September 29, 2025, 11:28pm UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-script-operation-during-daylight-savings-time-shift/111079/4 "2025-09-29T23:28:42Z")

</div>

```python
	#-------------
	# Get Gateways time
	#-------------
	GatewayDateTime=system.date.now()
	
	for TargetPLC in TargetPLCList:		
		try:		
			#-------------
			# Get PLC time
			#-------------
			PathPLCYear=Path+"/"+TargetPLC+"/RTC/Year"
			PathPLCMonth=Path+"/"+TargetPLC+"/RTC/Month"
			PathPLCDay=Path+"/"+TargetPLC+"/RTC/Day"
			PathPLCHour=Path+"/"+TargetPLC+"/RTC/Hour"
			PathPLCMinute=Path+"/"+TargetPLC+"/RTC/Minute"
			PathPLCSecond=Path+"/"+TargetPLC+"/RTC/Second"
			PathPLCSet=Path+"/"+TargetPLC+"/RTC/Set"
			PathPLCTags=[PathPLCYear,PathPLCMonth,PathPLCDay,PathPLCHour,PathPLCMinute,PathPLCSecond,PathPLCSet]
			PLCYear,PLCMonth,PLCDay,PLCHour,PLCMinute,PLCSecond,PLCSet = [x.value for x in system.tag.readBlocking(PathPLCTags)]
			
			#-------------
			#Convert to Date datatype
			#-------------
			PLCDateTime=system.date.parse(str(PLCDay)+"-"+str(PLCMonth)+"-"+str(PLCYear)+" "+str(PLCHour)+":"+str(PLCMinute)+":"+str(PLCSecond), 'dd-MM-yyyy HH:mm:ss')		
			
			#-------------
			# Compare PLC Time to Gateway Time
			#-------------
			MinutesDifference=system.date.minutesBetween(GatewayDateTime,PLCDateTime)
			Logger.info(str(TargetPLC)+" "+str(MinutesDifference)+" minute(s) differential with gateway")
			#-------------
			# If the allowable difference is exceeded, update the PLC time to the gateway time
			#-------------
			if abs(MinutesDifference) > AllowableDifference:
				GatewayYear=system.date.getYear(GatewayDateTime)
				GatewayMonth=system.date.getMonth(GatewayDateTime)+1
				GatewayDay=system.date.getDayOfMonth(GatewayDateTime)
				GatewayHour=system.date.getHour24(GatewayDateTime)
				GatewayMinute=system.date.getMinute(GatewayDateTime)
				GatewaySecond=system.date.getSecond(GatewayDateTime)
				PLCSet = 1
				system.tag.writeBlocking(PathPLCTags, [GatewayYear,GatewayMonth,GatewayDay,GatewayHour,GatewayMinute,GatewaySecond,PLCSet])
				Logger.info(str(TargetPLC)+" time synced with gateway")
		except:
			Logger.info(str(TargetPLC)+" failed to communicate")
			continue

```

![18467b0a1e4bdd233f289f8fa1d015ff95f25d30_2_690x69](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/b/7b3583f3da01b61a2e211106c921d4bac5325849.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/optimized/3X/6/3/633f2e404eed9c7724f616e2f372e6d8b3107202_2_690x47.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/optimized/3X/e/3/e34e8fefc7670d39cb904f73d70277858fd7ccb8_2_690x50.png)

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [September 29, 2025, 11:29pm UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-script-operation-during-daylight-savings-time-shift/111079/5 "2025-09-29T23:29:29Z")

</div>

For better readability, wrap your code in a code block tag, it makes it much easier to read.

---

<div class="post-metadata">

**Author:** ![SWoollett](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@SWoollett](https://forum.inductiveautomation.com/u/SWoollett)\
**Post date:** [September 29, 2025, 11:32pm UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-script-operation-during-daylight-savings-time-shift/111079/6 "2025-09-29T23:32:40Z")

</div>

updated with actual code rather than pseudocode

---

<div class="post-metadata">

**Author:** ![SWoollett](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@SWoollett](https://forum.inductiveautomation.com/u/SWoollett)\
**Post date:** [October 2, 2025, 12:53am UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-script-operation-during-daylight-savings-time-shift/111079/7 "2025-10-02T00:53:57Z")

</div>

I’ve added the Gateway time as part of the log message so will monitor next year to peak behind the scenes

---

<div class="post-metadata">

**Author:** ![Louis\_Whitburn](https://avatars.discourse-cdn.com/v4/letter/l/8baadc/32.png) [@Louis\_Whitburn](https://forum.inductiveautomation.com/u/Louis_Whitburn)\
**Post date:** [October 2, 2025, 3:46am UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-script-operation-during-daylight-savings-time-shift/111079/8 "2025-10-02T03:46:53Z")

</div>

I think at 03:01 your PLC ‘hour’ would be 2 and your gateway ‘hour’ would be 3?

On my gateway (Pacific/Auckland time zone) if I run

```python
system.date.setTime(system.date.getDate(2025, 8, 28), 2, 1, 0)
system.date.setTime(system.date.getDate(2025, 8, 28), 3, 1, 0)

```

Then I see

```plaintext
Sun Sep 28 03:01:00 NZDT 2025
Sun Sep 28 03:01:00 NZDT 2025

```

I guess the Java date / time library is clever enough to know that 2025-09-28 02:01:00 isn’t a ‘valid’ time and adjusts accordingly to the right offset.

It looks like your code will observe the same behaviour

![Screenshot 2025-10-02 164514](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/4/d4113f5855f224982b784621aef9ed17a823bc31.png)

Only at 04:01 will we see two different times

 ![Screenshot 2025-10-02 164126](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/b/bbdd45591661e023807a566e82e4934181150680.png)

---

<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 2, 2025, 11:12am UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-script-operation-during-daylight-savings-time-shift/111079/9 "2025-10-02T11:12:24Z")

</div>

If your PLC doesn't have proper timezone support, the Right Answer™ is to run the PLC clock in UTC all the time. Use java's `ZonedDateTime` to retrieve the current time at UTC and write its components to the PLC.

---

<div class="post-metadata">

**Author:** ![SWoollett](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@SWoollett](https://forum.inductiveautomation.com/u/SWoollett)\
**Post date:** [October 2, 2025, 8:53pm UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-script-operation-during-daylight-savings-time-shift/111079/10 "2025-10-02T20:53:17Z")

</div>

I had been going down the route of configuring NTP, Time zone and DLS on all our PLCs. However, I found there are a handful which don’t support these.

So my preference is rather than having various time keeping systems in place depending on what model the PLC happens to be, is to have one unified system.

Suffice to say… back to the drawing board, I’ll consider your suggestion

Thanks

---

<div class="post-metadata">

**Author:** ![SWoollett](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@SWoollett](https://forum.inductiveautomation.com/u/SWoollett)\
**Post date:** [October 2, 2025, 8:54pm UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-script-operation-during-daylight-savings-time-shift/111079/11 "2025-10-02T20:54:54Z")

</div>

Thanks! that is exactly the issue.  
here I was thinking I was being smart utilizing the built in tools. turns out the tools are smarter than I am!
