How to get datte and time in a event script (client/gateway)

Hello Everyone,
Technical support has not been able to answer my question so maybe one of you will.
I want to be able to run a gateway script base on a tag value change, the script would simply look at the current time off the system and base on a per-determine time would select a recipient to send an email to, I know its not something difficult to do but unfortunately the Ignitions Help does not Help.

Ignition Version: 7.2.11

IF TimeHR < 9 then:

Thanks in advance.

Try this:

from datetime import datetime
if myTime.hour < 9:

I don’t think that the datetime module was available in 7.2. Is there a specific reason why you don’t want to do the time comparison in an expression tag using the timeBetween() function and then read that tag in your script?

The reason that I’m proposing the tag option is because I believe the only other way to work with dates in scripting back in 7.2 is to import the Java Calendar and Date objects and use those. These objects are not difficult to use but they do add a bit of complexity to your script which may not actually be needed.

Here’s the alternative using calendar.

from java.util import Calendar
if myHour < 9:

Or if you want to use an expression, you can do this: