I have set up a date field on my form so that the date shows up automatically. Currently if i open the document today and save it, it has todays date. Tomorrow if I open the form again, it has the previous day's date. I would like the date to always be current-showing the date the file was opened. Can anyone explain how to do this?
I am using the following script in the ready:layout event
= xfa.timeStamp
i have had responses to previous posts about this but it is still not working correctly.
this.rawValue
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
I think there is a better approach. In the Object library if you scroll down to the Custom objects there is a current date object. If you drag this on and delete the previous object.
This has FormCalc in the layout:ready event, which will fire every time the form is opened (and more frequently, like when new objects added at runtime):
$.rawValue = num2date(date(), DateFmt(1))
Good luck,
Niall
Views
Replies
Total Likes
Hi,
I think there is a better approach. In the Object library if you scroll down to the Custom objects there is a current date object. If you drag this on and delete the previous object.
This has FormCalc in the layout:ready event, which will fire every time the form is opened (and more frequently, like when new objects added at runtime):
$.rawValue = num2date(date(), DateFmt(1))
Good luck,
Niall
Views
Replies
Total Likes
i am using javascript. can i still use what you suggested?
Views
Replies
Total Likes
Hi,
If this is the only script in the layout:ready event of this date stamp, then I would be inclined to stick with FormCalc for dates (and times). You can use javascript in different events in the same object and elsewhere in the form.
The events are separate and can use different languages.
If you have javascript script in the layout:ready event already and you want to share the space with the date stamp then you can achieve the same effect with Javascript using new Date(), but it is more involved:
var oNow = new Date();
this.rawValue = oNow.getDate() + "/" + (oNow.getMonth()+1) + "/" + oNow.getFullYear() +
" @ " + oNow.getHours() + ":" + oNow.getMinutes() + ":" + oNow.getSeconds();
Note: Months are zero-based, hence the +1
I hope that helps,
Niall
Thank you for your help Niall. I would like the date to show up in dd/mm/yyyy format, but right now it is shoing as mm/dd/yyyy. Do you know how to change this?
Views
Replies
Total Likes
Hi,
If you are using the FormCalc then you can replace the preset pattern to your specific requirements:
$ = Num2Date(Date(), "DD/MM/YYYY")
This should work, out of the box.
The Javascript solution should work as it basically concatenates the parts of the date.
Good luck,
Niall
Views
Likes
Replies