Copy link to clipboard
Copied
I tried the instructions below but it does not work:
In Acrobat:
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.
3. To create a document level script that is executed each time the document is opened, choose View > Tools > Document Processing > JavaScript > Document JavaScripts. Name the script Today, and click Add.
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.
5. Click OK in the JavaScript Edit dialog box, and then click Close in the JavaScript Functions dialog box.
The advice you were given above was misleading. You should not have just removed the "var f" part of the code. It broke it. Put it back and if you want to update the field also before the file is printed place it under Tools - JavaScript - Set Document Actions - Document Will Print as well.
The correct code is:
var f = this.getField("Today"); f.value = util.printd("mm/dd/yyyy", new Date());
Or:
this.getField("Today").value = util.printd("mm/dd/yyyy", new Date());
Copy link to clipboard
Copied
Try setting the value property as well.
Copy link to clipboard
Copied
I'm not aware of a way to do that. The date picker has a mind of its own and it doesn't look like you can change it.
Copy link to clipboard
Copied
I believe it does that by default when you click the empty field. Is that not the case?
Copy link to clipboard
Copied
No, it's empty at first. I want current date as default in date picker.
Copy link to clipboard
Copied
If you look closely you will see you are trying to use a different character for the format of the date.
I would set the form field format to "None" or the same format that you are using in the document level script.
This can also be version dependent. I have found consistent formatting for dates is important. It reduces confusion.
Have you opened the Acrobat JavaScript console to see if there are any errors?
The "var f = " is not necessary.
Copy link to clipboard
Copied
Thank you gkalserll. I'll try that and let you know.
Copy link to clipboard
Copied
Hi gkalserll, I tried your suggestion but it didn't populate current date. Thank you though for your input.
Copy link to clipboard
Copied
Autodate is a sample working form located on Dropbox that works and shows how the auto date field will not reset upon a form reset.
Note the use must be using a program, app, or web browser that can support JavaScript's date object, date formatting, document level scripts, etc.
Copy link to clipboard
Copied
can you help me set up an automated date form that will automatically fill it with the date 5 days from the current day?
Copy link to clipboard
Copied
This question has been asked and answered many many times. Have you searched the forum for "adding days"?
Acrobat forms use JavaScript and you will use the Date object that has may properties and methods that can be used to manipulate the date, like getDate() and setDate() . These methods can be used to get the date of the month from the date object and then one can adjust that value as needed and then the adjusted value can be used to set the date object to that new date.
Copy link to clipboard
Copied
i am a noob when it comes to coding. can you please give me the exact code for this to work? this would be so much help ! thank you!
Copy link to clipboard
Copied
Here is a tutorial that provides the code, and an example document
https://acrobatusers.com/tutorials/date_time_part1
Copy link to clipboard
Copied
I'm using Adobe Acrobat DC.
Copy link to clipboard
Copied
I can only share an image, video and link. There is no option for me to insert a file.
Copy link to clipboard
Copied
You cannot share a file directly here, you would need to make it available somehow, and then post the link here. The easiest way for you to share a file is using Adobe's Document Cloud service. See here for more information: Share Documents via Adobe's Document Cloud - KHKonsulting LLC
Copy link to clipboard
Copied
Found on this forum - works as a 'Custom calculation script'.
// get current system date object
var oNow = new Date();
// set value to formatted date string
event.value = util.printd("mm/dd/yyyy", oNow);
Copy link to clipboard
Copied
How do you do this in Acrobat Reader DC?
Copy link to clipboard
Copied
You cannot create forms or edit form field properties in the free Adobe Reader. This can only be done with Adobe Acrobat Pro or Standard.
Copy link to clipboard
Copied
worked perfectly, thanks!