Expand my Community achievements bar.

SOLVED

frustrating problem with a dat/time field

Avatar

Former Community Member

I'm pretty new to this tool (LiveCycle) - trying once again to edit/create a very simple writeable pdf form

I have inserted 2 date time fields. I have one set up correctly to auto insert the current time when the form opens so user does not have to do this..;

The next field should be a time field so the user does not have to enter that either.

I have the date field loading properly, but for the life of me cannot get the time to display at all.  I tried:

1. Addding a new date/time field

2. Duplicating the one that works and just changing the format to "Time"

3. Tried deleting both and then creating them again.

I discovered by deleting both and starting anew, that I can get the date to appear in both fields, but I cannot get anything else to appear.  I cannot get the time to appear in either field.!!

Frustrated:  Can someone tell me what I'm doing wrong here...

Since I don't see a place for me to upload the form here, I've posted at the following site

I think you can just download it and have a look - if someone would be so kind - might explain things better to see it for yourself.  It seems buggy to me, but I dont know!!!!!

Thanks ahead,

Dan A.

See it at: http://provsnusa.com/test.html

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Dan,

The time field still had date functions in the script, albeit you were using a time pattern (in the Object > Field > Patterns).

Just changed the script to:

// Current Time in short-style date format.

$ = num2time(Time(), TimeFmt(1))

Here is the form: https://acrobat.com/#d=63FQyQ3bVTlj8ERIjvUGJw

Good luck,

Niall

View solution in original post

4 Replies

Avatar

Correct answer by
Level 10

Hi Dan,

The time field still had date functions in the script, albeit you were using a time pattern (in the Object > Field > Patterns).

Just changed the script to:

// Current Time in short-style date format.

$ = num2time(Time(), TimeFmt(1))

Here is the form: https://acrobat.com/#d=63FQyQ3bVTlj8ERIjvUGJw

Good luck,

Niall

Avatar

Former Community Member

Thank you very much...

Being new to this tool, - is this a buggy work around or did I just not know any better?  I did not see in the help documentation that I had to write a function (JavaScript looks like) to modify the field.  I thought it would be straightforward and easy by changing the selection to "Time".  I did see in these forums that many are writing their own functions, I just didn't quite get where to place it.

Any insight for the future would be helpful

Thank you very much again for your help Niall.

Dan

Avatar

Level 10

Hi Dan,

This is expected behaviour - it is not buggy.

Setting the DateTimeField to 'Time' just sets the field up to display a time. For example if you look at the Patterns in the Object > Field tab, you will see that the Date field automatically has date patterns, whereas the Time field has time patterns.

LC Designer is very flexible, but to get the most out of it involves scripting. There is a lot of help on the Adobe pages and I can recommend a book 'LC Designer Forms' by JP Terry and www.pdfscripting.com, which is a subscription service.

The date and time functions are FormCalc, which is a proprietary scripting language by Adobe. FormCalc is very good for dealing with dates, as it has excellent builtin functions.

The other language is Javascript, which I tend to use as a personal preference. FormCalc is meant to be a bit more efficient, but when you are used to one syntax, I tend to stick with it.

From the examples, you will have seen the Script Editor at the top of the LC Designer window (available from the Window menu). By default this is only one line high, so I would recommend making this bigger, so that you can see a block of script at any one time. Also this is where you will set the events that you will script against.

The latest version of LC Designer ES2 (version 9) includes an 'Action Builder' that helps you generate the script, by selecting choices (eg show/hide objects). I have not used it in anger yet, but it may be of interest.

Hope that helps,

Niall

Avatar

Level 3

Use below code to set the filed value to current Time

create new Text Field and insert below code in initialize :

//Current Time Jk

var d = new Date();

    this.rawValue = d.toLocaleTimeString();