I have a random value of milliseconds, for example 105984. How can I format it to HH:mm?
Example value is approx 1,7 minutes, which would convert to 00:02 or 00:01 depending on rounding. Values can be anything below 24 hours.
Rounding isn't an issue here because the value is updated rarely and doesn't need to be exact. But it would be awesome if you could give some tips on that too.
Formatting time
Moderator: Martin
Re: Formatting time
Hi,
You could use {105984,dateformat,timezone,UTC,HH:mm} respectively {variable,dateformat,timezone,UTC,HH:mm}. UTC will ensure that no timezone offset is in use.
The dateformat in this mode behaves like it's rounding down to the minute since it does not show the seconds. You could simulate to round up to the minute by adding 30000ms: {variable+30000,dateformat,timezone,UTC,HH:mm}. Values below 90000ms will still show as 00:01, values above 90000ms will show as 00:02.
Regards,
Martin
You could use {105984,dateformat,timezone,UTC,HH:mm} respectively {variable,dateformat,timezone,UTC,HH:mm}. UTC will ensure that no timezone offset is in use.
The dateformat in this mode behaves like it's rounding down to the minute since it does not show the seconds. You could simulate to round up to the minute by adding 30000ms: {variable+30000,dateformat,timezone,UTC,HH:mm}. Values below 90000ms will still show as 00:01, values above 90000ms will show as 00:02.
Regards,
Martin
Re: Formatting time
I tried the same earlie but without timezone and utc arguments. It didn't work. Are those required or did I have a typo somewhere?
Anyway, now it works great. Thanks!
Anyway, now it works great. Thanks!
Re: Formatting time
It should also work without the timezone and UTC but will give a result that's shifted by the timezone offset currently in use by your device. In my location I would get a result shifted by one hour so {105984,dateformat,HH:mm} shows 01:01.
Re: Formatting time
It must have been a typo then, although I checked it many time that the code is correct. Still, there would have been a problem with timezone, because I wasn't aware of that. I got many problems solved with your answer.
Thanks again!
Thanks again!