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

Invoice to convert HH:MM to decimal time

New Here ,
Apr 16, 2024 Apr 16, 2024

Copy link to clipboard

Copied

I am trying to create an Fillable PDF Invoice for my business that I can fill out in Arobat that will auto calculate my total hours in decimal when I add them in the field.

Example: (HH:MM) 3:50 = (decimal time) 3.83

I realized it may need a javascript formula to do this. 

I don't quite know how to set this up, where to put the javascript and etc. Appreciate the help. 

Here is how I have it setup. 

Screenshot 2024-04-16 at 11.43.33 PM.png

TOPICS
Create PDFs , Edit and convert PDFs , How to , JavaScript , PDF , PDF forms

Views

224

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

correct answers 1 Correct answer

Community Expert , Apr 17, 2024 Apr 17, 2024

To convert time to decimal, you can use this as custom calculation script of 'decimal' field (change field names in script for other fields:

 

function convertTimeToDecimal(timeStr) {
 var parts = timeStr.split(':');
 if (parts.length === 2) {
 var hours = parseInt(parts[0], 10);
 var minutes = parseInt(parts[1], 10);
 return hours + minutes / 60;}
 return 0;
}

var timeInput = this.getField("hh:MM 1").value;
event.value = convertTimeToDecimal(timeInput).toFixed(2);

 

Votes

Translate

Translate
Community Expert ,
Apr 17, 2024 Apr 17, 2024

Copy link to clipboard

Copied

To convert time to decimal, you can use this as custom calculation script of 'decimal' field (change field names in script for other fields:

 

function convertTimeToDecimal(timeStr) {
 var parts = timeStr.split(':');
 if (parts.length === 2) {
 var hours = parseInt(parts[0], 10);
 var minutes = parseInt(parts[1], 10);
 return hours + minutes / 60;}
 return 0;
}

var timeInput = this.getField("hh:MM 1").value;
event.value = convertTimeToDecimal(timeInput).toFixed(2);

 

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
New Here ,
Apr 17, 2024 Apr 17, 2024

Copy link to clipboard

Copied

This worked! Thanks so much!

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
Adobe Employee ,
Apr 26, 2024 Apr 26, 2024

Copy link to clipboard

Copied

LATEST

Hi @Keeemara

 

We are glad to hear that it worked for you.

 

Marking a reply or response “Correct” will help future users with the same issue quickly identify the correct answer.


~Amal

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