DateTime Conversion (openHAB 3.x)

Something like this (?):
Post current time to item
My_Item.postUpdate(new DateTimeType())

Get Epoch from Item:
val Number item_millis = (My_Item.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli

Get Now Epoch:
val Number now_millis = now.toInstant.toEpochMilli

Difference in Minutes:
var Number diff = (now_millis - item_millis)/60000

3 Likes