I need to set the timeout on a timer that takes milliseconds.
I have a DateTime item.
I need to convert that to epoch milliseconds, then subtract from epoch now, and set the timer with that time delta.
I am unable to find documentation that describes how to get the epoch from a DateTime item.
You don’t need to do all of that. There’s a
millisFromNow() method on ZonedDateTime and
time,toZDT() will convert the DateTime Item or the rawState to a ZonedDateTime.
var delay = time.toZDT(items.getItem("MyDT")).millisFromNow();
var delay = time.toZDT(items.getItem("MyDT").rawState).millisFromNow();
However, in all cases, as documented, an Item’s
.state always returns the String representation of the state. And also as documented, the library can’t process the toString if it includes the timezone.