Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Adobe fillable form field HH:MM displaying MM inaccurately

Community Beginner ,
May 04, 2023 May 04, 2023

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.

TOPICS
JavaScript , PDF forms
5.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
2 ACCEPTED SOLUTIONS
Community Expert ,
May 09, 2023 May 09, 2023

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.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 09, 2023 May 09, 2023

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.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 04, 2023 May 04, 2023

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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 05, 2023 May 05, 2023

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 05, 2023 May 05, 2023

It's possible, but you need to define exactly when it should be updated. What should be the trigger for it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 05, 2023 May 05, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 05, 2023 May 05, 2023

If you want to do it via a button then it has to be done using a script.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 05, 2023 May 05, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 05, 2023 May 05, 2023

Look at this article:

https://acrobatusers.com/tutorials/working-date-and-time-acrobat-javascript-part-3-3/

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 05, 2023 May 05, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 05, 2023 May 05, 2023

Thank you. I will let you know how it works out for me.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 05, 2023 May 05, 2023

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());

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 05, 2023 May 05, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 08, 2023 May 08, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2023 May 08, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 09, 2023 May 09, 2023

I am sure your code works, but I am just not connecting the dots to get it setup correctly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 09, 2023 May 09, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 09, 2023 May 09, 2023
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 09, 2023 May 09, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 09, 2023 May 09, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 09, 2023 May 09, 2023
LATEST

> Also, I didn't set the Action of the Text field to Execute a Menu Item.

Nor should you have...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines