I tried the instructions below but it does not work:
The script you create to display the current date when the document is opened is a document level script.
To create an automatic date field:1. Select Tools > Forms >. Edit > Add New Field > Text Field and create a text field. (For more infor-mation, see the section on Creating Form Fields in the Acrobat online help.) Select All Properties > General tab and name the field Today.
2. Select the Format tab, chooses Date for the format category, and chooses a month, day, and year format option (for example, “mmm d, yyyy”). On the General tab, make sure the field is read-only because it will be a calculated field, and click Close.
4. Delete the automatically generated text, defining a Today function, that is displayed in the script window. Type in the following text in the exact format (line wraps are OK) and click OK.
var f = this.getField("Today");f.value = util.printd("mm/dd/yyyy", new Date());
This script binds the Today field to the variable f, and then calculates the value. The newDate() ex-pression creates a new date object initialized to the current date and time. The util object is used to format the date into the month/day/year format.
"Does not work" is not very helpful... What exactly happened when you tried it?
It does not populate current date
Again, this is not very helpful. You need to provide exact details.
Hi try67. Populating current date is what I'm trying to achieve. Following directions above didn't help as the document becomes stagnant from the date I did it. It should change current date everyday, for example when you print the document, it would reflect the current date. In this case, it failed to do it.
Can you share the file?
See attached file. I removed the content for proprietary protection.
This is a screenshot of the file. You need to share the ACTUAL file.
You need to change this line:
var f = this.getField("Today");
Or better yet, replace the entire script with this one line:
getField("Today").value = util.printd("mm/dd/yyyy", new Date());
The correct code is:
var f = this.getField("Today"); f.value = util.printd("mm/dd/yyyy", new Date());
this.getField("Today").value = util.printd("mm/dd/yyyy", new Date());
Thank you. I'll try that and I'll let you know if it works.
Hello try67. It is finally working. The document populated a current date. Thank you! You're the man!
This isn't working for me. I created a text field, named it "Today", created a Document Script and set the field's value per your answer. Nothing happens. I've tried saving the PDF and reopening it to see if that would get things working, but nothing.
I have had Adobe Acrobat Pro DC for about a day now, so I'm definitely fresh. I have version 2019.008.20071. Let me know if you need more info from me, thanks in advance!
Delete the function definition, or add this to the end of your code:
You're working with an Adobe Sign form, not a regular Acroform, so the field name isn't what's shown in the Name field of the Properties dialog. You can see the actual name in the fields list in the right-hand pane, but the script won't work when used with Adobe Sign anyway. It will work if you convert to a regular Acroform though.
What PDF viewer are you using?
Not all PDF viewers support document level scripts.
How do I set default value as today's date in Date picker. Please help
You're going to have to provide more details. For example, do you want to have it default to the current date only if the field is blank at the time the user is interacting with the field, or something else?
Yes, default value as todays date in date picker when the user open the form and also have ability to change it later if he wants.
Add this code as a doc-level script (not in a function):
this.getField("Date1").defaultValue = util.printd("mm/dd/yyyy", new Date());
Change the field name and date format as needed.
How do I go to doc level script?
I did that and it's not working for date picker.
I works for Text box and not date picker.