# (Unit of Measure, Time) - Seconds to M:S time to show on Page/OH-Card

**URL:** <https://community.openhab.org/t/unit-of-measure-time-seconds-to-m-s-time-to-show-on-page-oh-card/142739>\
**Category:** Beginners\
**Tags:** timer, rules, items, jsscripting\
**Created:** [December 30, 2022, 8:55pm UTC](https://community.openhab.org/t/unit-of-measure-time-seconds-to-m-s-time-to-show-on-page-oh-card/142739 "2022-12-30T20:55:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkca916](https://community.openhab.org/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tkca916](https://community.openhab.org/u/tkca916)\
**Post date:** [December 30, 2022, 8:55pm UTC](https://community.openhab.org/t/unit-of-measure-time-seconds-to-m-s-time-to-show-on-page-oh-card/142739/1 "2022-12-30T20:55:14Z")

</div>

(Unit of Measure, Time) - Seconds to M:S time to show on Page/OH-Card

Hello,

I am currently working on building a simple countdown timer and now I am looking at figuring out how to display the time on my page in an easy viewable manner. After finding the action timer ([Action Timers](https://www.openhab.org/docs/configuration/actions.html#timers)) example I got basic countdown going now. I was able to calculate and show 30 second intervals by building a secondary rules/script to update a countdown number. By looking at what was done on the [Washing machine status widget](https://community.openhab.org/t/washing-machine-status-widget/116621).

After hoping that defining the number as Number:Time to get to a formatting that I can find to work, it looks like per this post, Number Time UoM , this is not possible.

Number I am trying to convert in gui is shown in the image, I don’t know of another way to capture the full view of an item configurations. I do have the JS scripting installed under automation.

However, in the thread stream they mention using a script to convert the numbers to min and seconds. I have placed the script in the transform folder,but through the GUI, how do I call out that transform script?

I have tried replacing the %0.2f with “[JS(clockfmt.js):%s]” which lead to the system saying the JS was “Couldn’t transform value because transformation service of type ‘[JS’ is not available.”

Basic System:Openhab3.4 on Openhabian.

Any help or direction to further documentation on using scripting to change formatting would be greatly appreciated.

Thanks

 ![Timer_1_IMG-2](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/8/e/8ec6d896b9d4ae7e5ff4a9cca09f0eb94f64ac7a.png)  
 ![Timer_1_IMG-1](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/0/7/0751c5beae7b163d3953f5e8c60ca3a92218f1f5.png)

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [December 31, 2022, 2:40am UTC](https://community.openhab.org/t/unit-of-measure-time-seconds-to-m-s-time-to-show-on-page-oh-card/142739/2 "2022-12-31T02:40:17Z")

</div>

> [@tkca916](#):
>
> After hoping that defining the number as Number:Time to get to a formatting that I can find to work, it looks like per this post, Number Time UoM , this is not possible.

A Number:Time Item can be formatted the same as a DateTime to get HH:MM:SS formatting.. Something like `%1$tH:%1$tM:%1$tS` in the state description will break the time up into hours:minutes:seconds.

> [@tkca916](#):
>
> how do I call out that transform script?

See [Items | openHAB](https://www.openhab.org/docs/configuration/items.html#state-transformation). You can include a transformation as part of the state description pattern. But if you have a Number:Time it’s not necessary. Use DateTime formatting and as long as the time isn’t larger than 30 days it will work just fine.

---

<div class="post-metadata">

**Author:** ![tkca916](https://community.openhab.org/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tkca916](https://community.openhab.org/u/tkca916)\
**Post date:** [December 31, 2022, 4:37am UTC](https://community.openhab.org/t/unit-of-measure-time-seconds-to-m-s-time-to-show-on-page-oh-card/142739/3 "2022-12-31T04:37:04Z")

</div>

Thanks, that worked. I guess I had my blinders on and got caught in keeping same type of variables.

---

<div class="post-metadata">

**Author:** ![system](https://community-openhab-org.s3-eu-central-1.amazonaws.com/original/2X/6/6a52f2ac5d00e4c7b50471a354b3a9221188be90.png) [@system](https://community.openhab.org/u/system)\
**Post date:** [February 10, 2023, 8:37pm UTC](https://community.openhab.org/t/unit-of-measure-time-seconds-to-m-s-time-to-show-on-page-oh-card/142739/4 "2023-02-10T20:37:08Z")

</div>

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.
