Date/Time driving me nuts. How to set Time automatically?

Avatar

Avatar

carrienmsd

Avatar

carrienmsd

carrienmsd

21-03-2011

Ok ok.  Hope someone can help me out here!

I tried this in Acrobat Pro first, but I dont know Javascript and so couldn't modify the "Call Date" script to get the Time instead.

Fortunately, I also have Livecycle and everything looked so simple BUT it's not working.

Let me explain what I'm trying to do.  My boss asked me to develop a log entry form in where after the user types in an entry and leaves the field then the time of the entry is automatically logged.  This field should be unalterable.

I set up a Text Field (to act as the log entry form field).  I then set up a Date/Time field.  I went to Binding and changed it to Time.  I changed the Value to Read Only, and then the Pattern to h:MM A. 

Set up the action- when user exits the text field, the Date/Time field value is inserted automatically.

This works beautifully EXCEPT I only get the DATE!  I've tried Protected, Read Only (calculated) etc.  This requires a script to be called.... the very thing I hoped to avoid since I can't code.  RunTime worked somewhat-- but in the PDF itself, when the user exits the text field, the date AND time shows up, but if that field is clicked, the time is updated.  I don't want it updated.  My boss wants to see the time that the log entry was completed so it can't be changed by the user or updated.

I hope I'm clear as to what I need.  Anybody can help?  Hope so!

Thanks--

-carrie

View Entire Topic

Avatar

Avatar

gkaiseril

Avatar

gkaiseril

gkaiseril

21-03-2011

Are you creating your form in Acrobat or LiveCycle Designer. A little hare to tell with all of your posts.

For Acrobat forms:

You can get a lot of different information from the date object by changing the format string for the 'util.printd' method. See the reference George Johnson links to for the format string values that can change the displayed value.

// get new Date object
var d = new Date();

// format to h:MM tt
var sDate = util.printd("h:MM tt", d);

// insert date into form field
this.getField("todaysDate").value = sDate;

h - hours without leading zero

MM - minutes with leading zero if necessary

tt - am or pm designator

For LiveCycle Designer you can select the 'Custom' form tab and then the 'Current Date' field. Now change the script to:

$.rawValue

= num2Time(time(), TimeFmt(1))

More information about the time format is the 'Scripting Reference' under LiveCycle Designer's 'Help' menu option.

For the field object, you can set the "Value" "Type:" option to "Calculated - Read Only". But if you use the predefined 'Current Date' field, this is already done for you.