Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - DateTime Calculation
  FAQ FAQ  Forum Search   Register Register  Login Login


Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

DateTime Calculation

 Post Reply Post Reply
Author
JavaNovice View Drop Down
New Member
New Member


Joined: 27 Mar 2013
Location: Texas
Points: 2
Post Options Post Options   Quote JavaNovice Quote  Post ReplyReply Direct Link To This Post Topic: DateTime Calculation
    Posted: 27 Mar 2013 at 2:47pm
I have an adobe acrobat x form with two fields:  Start Date/Time and End Date/Time.  They are formatted m/d/yyyy HH:MM for 24hr segments.

Can the difference between the fields be calculated to get Total Down Hours?

I am very new to javascript and appreciate any help anyone can give!

Thanks!
Back to Top
Sponsored Links


Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4108
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 28 Mar 2013 at 7:05pm
Yes, but you need a custom JavaScript calculation.
 
Date arithmetic is one example.
 
One possible method using a function to reduce repeated computation:
 
function Date2Num(cFormat, cString) {
// convert cString with cFormat to number of minutes from Epoch date
// convert to date time object
var oDate = util.scand(cFormat, cString);
// convert date time object to minutes
return Math.floor(oDate.getTime() / (1000 * 60));
} // end Date2Num function

// format for inputted date & time
 var cDateFormat = "m/d/yyyy HH:MM";
 // field names
 var cStartField = "Start Date/Time";
 var cEndField = "End Date/Time";
 // get field values
 var cStart = this.getField(cStartField).value;
 var cEnd = this.getField(cEndField).value;
 // clear the result value
 event.value = "";
 // compute the difference in minutes if there is data
 if(cStart != "" && cEnd != "") {
 var nDiff = Date2Num(cDateFormat, cEnd) -  Date2Num(cDateFormat, cStart);
 // convet to hours
 event.value = nDiff / 60;
 }
 
Back to Top
JavaNovice View Drop Down
New Member
New Member


Joined: 27 Mar 2013
Location: Texas
Points: 2
Post Options Post Options   Quote JavaNovice Quote  Post ReplyReply Direct Link To This Post Posted: 01 Apr 2013 at 3:53pm
Thank you so much!  That works like a charm.

Javascript is quite different from visual basic!

Thanks again...you are awesome and I truly appreciate your help!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.070 seconds.