How to extract hour and min from DateTime

Alright.
Datetimes in general are a complex topic, you should probably review -

Don’t approach this as a trivial job at all.

Take it on trust that it is almost always best to get a DateTime Item state into a rule as a ZonedDateTime type java object, because the ZDT comes with a lot of useful methods.

logInfo("test" , "Etuvalot state " + Etuvalot_Off.state.toString)

// get OH Item state as ZDT object
val EtuvalotZDT = (Etuvalot_Off.state as DateTimeType).getZonedDateTime

// get parts
val evHour = EtuvalotZDT.getHour
logInfo("test" , "Etuvalot hour " + evHour.toString)

Be sure to tell the GUI what script language you are using.

1 Like