Using Time Span function with time in milliseconds

Hello,

Is there a way to properly use the Time Span function with time in milliseconds or seconds?

I have an application that send a variable to KLWP which is a time in the future in milliseconds. I would like KLWP to display it as “16 hours from now” or “moments from now,” etc. This is what I am trying:

$tf(br(ha, next_alarm))$

The actual value of br(ha, next_alarm) is 1745157600000 which is Sun Apr 20 7:00 am (tomorrow), but this brings me “7 Decades.”

Maybe there’s a format I should convert it to first?

Any suggestions would be greatly appreciated.

Hi there,

As far as I know, Kustom preset does not support the millisecond for the time,

As for showing the next alarm, you can use this function without any third-party app needed:

$if(
  si(alarmon)=1,
  tf(si(alarmd)),
  "Alarm off"
)$

I hope this would help.
:smiling_face::+1:

Thank you. I cannot use the built-in Kustom alarm function because it shows the next alarm regardless of which app it comes from. Unfortunately, I have other apps that create alarms, but I only want to show the next one from the CLOCK app.

It’s strange that custom does not support the time span feature on time in milliseconds or seconds, because I am able to format it properly using this:

$df(“EEE h:mm a”, (br(ha, next_alarm)/1000))$

It returns Sun 7:00 AM, which is correct.

I figured it out.

For those of you that would like to do something like this, here’s how I did it:

$br(ha, next_alarm)$ is this : “1745157600000” which is the next alarm time in milliseconds

and then formatted would be:

$df("EEE h:mm a", (br(ha, next_alarm))/1000)$ is this: “Sun 7:00 AM”

and then to apply the Time Span function:

$tf(df("YYYY'y'MM'M'dd'd'hh'h'mm'm'ss's'", (br(ha, next_alarm))/1000))$ is this: “9 hours from now”

1 Like