These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Adding current time

greeneye82
Registered: Aug 3 2011
Posts: 1

I'm creating a form for my staff to fill in. When they open the form up to start there entries, I want the time to be automatically generated and placed on the form.
I do not want the time to adjust every time they make edits, only want it inputted once when they open the form initially. I think I figured out how to do this with the date, but the time I cannot figure out.
Step-by-step instructions would be great!!!!
 
thanks, and I am brand new to Acrobat X pro

My Product Information:
Acrobat Pro 10.1, Macintosh
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You can use the Acrobat JavaScript 'util.printd()' method to format the Date object into a string that can include the date or time.A much longer process can be done using the JavaScript date object methods that include a number of methods for time items.


The following script shows how to get the same display using both methods. To get the spelled out month requires additional code for the lookup in JavaScript.

var oDate = new Date();
// using util.printd;
var sDateTime = util.printd("m/d/yyyy HH:MM:ss", oDate);
console.println(sDateTime);

// using JavaScript methods
var nFullYear = oDate.getFullYear();
var nMonth = oDate.getMonth() + 1;
var nDate = oDate.getDate();
var nHours = oDate.getHours();
var nMinutes = oDate.getMinutes();
var nSeconds = oDate.getSeconds();
sDateTime = nMonth + "/" + nDate + "/" + nFullYear + " " + nHours + ":" + nMinutes + ":" + nSeconds;
console.println(sDateTime);

George Kaiser