Copy link to clipboard
Copied
Hello
Need help with script, changing decimal time field to hours and minutes . Thanks
Copy link to clipboard
Copied
What do you mean by "decimal time", exactly? Do you mean something like 1.5 should become 1:30?
Copy link to clipboard
Copied
Hi
Yes that is what I mean . What script could I use to change from decimal to hours and minutes. Thanks
Copy link to clipboard
Copied
You can use this code as the custom calculation script of the second field (adjust the name of the first one as needed):
var v = Number(this.getField("Text1").valueAsString);
var hours = Math.floor(v);
var minutes = (v-hours)*60;
var minutesString = (minutes<10) ? "0"+minutes : ""+minutes;
event.value = hours + ":" + minutesString;
Copy link to clipboard
Copied
Thank you . This worked perfectly
Copy link to clipboard
Copied
Hello, It's working but creating another decimal after minutes such as I need to convert 4.62 to minutes and results is 4:36.92 I wouldn't see .92 Would you help me please ?
Copy link to clipboard
Copied
Sorry, I don't follow what you mean... Do you want to display the result in a decimal value, instead of a time format (so 3.5 instead of 3:30)?
Copy link to clipboard
Copied
I want to display the result in a time hh:mm instead of a decimal value (so 3:30 instead of 3.5).
I have tried with your given script the result is 3:32.49 instead of 3.54. I need only 3:32 dont need extra 49 Please see the attached.
Copy link to clipboard
Copied
The script I posted doesn't include seconds at all, only hours and minutes.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now