I usa that to transform seconds into minutes and hour in JSON, but unfortunately the results I got is for example instead of 18:00, it gives me 18:0
{{floor(13.sekundy / 3600)}}:{{floor((13.sekundy % 3600) / 60)}}
Please hel me with this, for exaple if time is 12:30, then correct data is going to JSON, but when there are double 00, it gives me like example above like 18:0 instead of 18:00.
How to add this leading zero ?
I read other question but i didnt get it properly.
Sorry for stupid question.
Best regards !
Hi @Maciej_Walentynowicz,
If your input is in seconds the easiest would be to use a totally different formula:
{{formatDate(13.sekundy * 1000; “mm:ss”)}}
4 Likes
Hello @Maciej_Walentynowicz and welcome!
Make is doing this because the result of the calculation is a number.
One way to handle this is to check if the result is a 0 and if so, return “00”, by concatenating two strings, each containing “0”.
This example returns a string formatted as hh:mm:
{{floor(13.sekundy / 3600)}}:{{if(floor((13.sekundy % 3600) / 60) = 0; toString(0) + toString(0); floor(13.sekundy / 3600) + “:” + floor((13.sekundy % 3600) / 60))}}
Here’s another example which basically parses text as a date then reformats it as HH:mm:
{{formatDate(parseDate("1970-01-01 " + floor(13.sekundy / 3600) + “:” + floor((13.sekundy % 3600) / 60); “YYYY-MM-DD HH:mm”); “HH:mm”)}}
I’m curious if there’s a better or easier way to handle this though, so we’ll see what others have to say!
3 Likes