Copy link to clipboard
Copied
When I select the date/time field, it displays the minutes with a value of :05, even though the system time shows the real current time.
Copy link to clipboard
Copied
I don't see any buttons for setting the time when the user clicks them... So I added them for you, just above the first two fields, and applied the code to them. I also removed all other code fragments you had under those fields, and set their Format to None. See attached.
Copy link to clipboard
Copied
Thank you much! Now I see where I was going wrong. I had a button at the top of the form I was playing around with, but what I didn't do was reference the Text field from the Button in the Javascript. Also, I didn't set the Action of the Text field to Execute a Menu Item.
Copy link to clipboard
Copied
When you specify the pattern make sure to use upper-case letters, as "mm" stands for Month, not Minutes (which is "MM"). Hence the "05" result you're getting...
Copy link to clipboard
Copied
Thank you. That was the issue! However, now I am noticing that h, MM and ss only display the time when the form was first opened. In other words, they are not pulling the current system time, and I can only assume that mm and dd would do the same thing, if I waited long enough to test that theory. Is this by design? Is there a way to get current system time just like the digital signature does?
Copy link to clipboard
Copied
It's possible, but you need to define exactly when it should be updated. What should be the trigger for it?
Copy link to clipboard
Copied
Well, ideally what we would like are Start and Stop buttons for the user to just click and record the current system time. This will help them keep track of how much time they are spending on specific tasks. Sort of like a stop watch. The simplest way I found (without writing Javascript) is to just have the user select a date field and select the current day. By adding the time to the format, the user would be recording the current date and time.
Copy link to clipboard
Copied
If you want to do it via a button then it has to be done using a script.
Copy link to clipboard
Copied
Yes, we would want to use a button but would need help writing a script. So in lieu of that, what we need is to just see the function work. We will take the simplest method just as long as we can get the current system time. The field type and trigger could be anything at this point.
Copy link to clipboard
Copied
Look at this article:
https://acrobatusers.com/tutorials/working-date-and-time-acrobat-javascript-part-3-3/
Copy link to clipboard
Copied
The code itself is very simple:
this.getField("Date1").value = util.printd("mm/dd/yyyy HH:MM", new Date());
Adjust the field name and/or date pattern as needed.
Copy link to clipboard
Copied
Thank you. I will let you know how it works out for me.
Copy link to clipboard
Copied
What type of field is this code using? If I use a date field, it doesn't use the Javascript. If I change the field type to none, it also doesn't seem to use the Javascript. I am making certain the field name is the same. There are also no script errors when I add the Javascript Actions -> On Focus -> Run Javascript.
this.getField("Date1").value = util.printd("mm/dd/yyyy HH:MM", new Date());
Copy link to clipboard
Copied
The trigger should be the Mouse Up event of a button field, and the target should be a text field, with the Format set to None or to Date.
Copy link to clipboard
Copied
Apologies in advance for my ignorance, but I am not understanding how a button field and text field are linked together. Button Properties only show me the Actions tab where I can define a Mouse Up event to run JavaScript, whereas Text Field Properties show me Actions, Format, Validate, and Calculate tabs.
Copy link to clipboard
Copied
You wrote: "ideally what we would like are Start and Stop buttons for the user to just click and record the current system time."
Well, my code does just that. It uses the Mouse Up event of a button field to populate a text field with the current system time.
Copy link to clipboard
Copied
I am sure your code works, but I am just not connecting the dots to get it setup correctly.
Copy link to clipboard
Copied
I don't know how to explain it any more clearly than that... If you want further help you'll need to share the actual file.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thank you much! Now I see where I was going wrong. I had a button at the top of the form I was playing around with, but what I didn't do was reference the Text field from the Button in the Javascript. Also, I didn't set the Action of the Text field to Execute a Menu Item.
Copy link to clipboard
Copied
> Also, I didn't set the Action of the Text field to Execute a Menu Item.
Nor should you have...
Find more inspiration, events, and resources on the new Adobe Community
Explore Now