Skip to main content
April 10, 2019
Question

I am looking for a javascipt to convert decimal minutes to hours and minutes?

  • April 10, 2019
  • 1 reply
  • 619 views

Good Day,

I am looking for a javascipt to convert decimal minutes to hours and minutes?

On my form i have four fields that is have added up to give me a Total. These fields can be any numbers in them

Example Field 1 - 60 Mins

Field 2 - 60 Mins

Field 3 - 50 Mins

Field 4 - 60 Mins

Total - 230 Mins

then i take Total(230 mins) / 60 mins = FinalTotal(3.83) (Decimal Minutes)

I need to take the Final Total(Decimal Minutes) 3.83 and convert it to Hours and Minutes to get the final answer of 3 Hours & 50 Minutes

Any help would be grealy appreciated

Thanks

This topic has been closed for replies.

1 reply

April 10, 2019

I have this code:

Just want to know where to place this code? do i put it under calcualtion tab under custom scripts?

VarFinalTotal= this.getField("FinalTotal");

var timeConvert = function(n){

var minutes = n%60

var hours = (n - minutes) / 60

console.log(hours + " " + "Hours" + " " + ":" + " " + minutes + " Minutes")

}

timeConvert(VarFinalTotal);

Bernd Alheit
Community Expert
Community Expert
April 10, 2019

console.log doesn't exists in Adobe Acrobat.