• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Apr 09, 2019 Apr 09, 2019

Copy link to clipboard

Copied

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

TOPICS
Acrobat SDK and JavaScript , Windows

Views

455

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 09, 2019 Apr 09, 2019

Copy link to clipboard

Copied

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);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 10, 2019 Apr 10, 2019

Copy link to clipboard

Copied

console.log doesn't exists in Adobe Acrobat.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 10, 2019 Apr 10, 2019

Copy link to clipboard

Copied

As Bernd pointed out, JavaScript for Acrobat is different from other JavaScript implementations. Take a look at this post, which talks about the differences in the context of how to learn to program in JavaScript for Acrobat: Learning to Program JavaScript for Adobe Acrobat - KHKonsulting LLC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 10, 2019 Apr 10, 2019

Copy link to clipboard

Copied

LATEST

There are a number of errors in your script.

I would also look at using the "util.prinf()" method to format the output as "h:MM"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines