Remove colon from Time

I am trying to store a number in a virtual device, but none supports time format. So
i want to store it as a number instead, like 17:22 to 1722. Or just the 2 last digits?
Any chance this could be done through logic or something?

You can convert it with Homeyscript in AdvancedFlow:

This card takes a input token, replaces the “:” and returns a number. Place your time token in teh highlighted field.

return Number(args[0].replace(':', ''));
1 Like

Ty for the script example. Tested it and i get the correct output as a number.
But then, how can i take that number and store it into a virtual device?
I am trying to store it as a power number in a virtual lamp.

Update: figured it out. Flow tag from the script did show up at the top of the tag selection.

That depends on the app you used for virtual devices and the capability used (numeric like measure* ?).

I figured it out, se update above.
Ty so much for the help :slight_smile:

1 Like

You can also use the Foemat date flowcard from BetterLogicLibrary with format HHmm.

I did try that before this topic was created, and i made a “minutt” format using “mm”.
It ended there as i could not figure out how to use that in the flow.

For you and anyone else interested, I felt like visualizing the BLL flow possibility in addition to the solutions posted here.

The BLL card ‘Format date as …’ returns the result of your entered format right away as you type:

To save the time without colon as numeric variable:


Nice example, finaly got to see how it worked. Ty for that.

Below is how i used the homeyscript solution + how your example also could be used.

1 Like

YW. Arnt,

Yeah, the advantage of the HS cards is it returns a numeric tag right away, albeit a local (flow only) tag.

But I can imagine folks not wanting to use HS cards (yet) :stuck_out_tongue_winking_eye:

I ended up using the BetterLogicLibrary, as it turnes out i could not save a converted time with a 0 at the begining, like 0922. It would save it as 922. Using BLL i formated time using “m” not “mm”. If i understand this correctly, it will return a number as 5, instead of 05.

1 Like