Beenden
  • Globale Community
    • Sprache:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

Adobe fillable form field HH:MM displaying MM inaccurately

Community-Einsteiger ,
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.

THEMEN
JavaScript , PDF Forms
5.8K
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
2 AKZEPTIERTE LÖSUNGEN
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.

Lösung in ursprünglichem Beitrag anzeigen

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
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.

Lösung in ursprünglichem Beitrag anzeigen

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
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...

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
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?

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
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?

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
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.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
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.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
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.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
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

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
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.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
May 05, 2023 May 05, 2023

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

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
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());

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
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.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
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.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
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.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
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.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
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.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
May 09, 2023 May 09, 2023
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
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.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
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.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
May 09, 2023 May 09, 2023
AKTUELL

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

Nor should you have...

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines