Hi,
I have 2 date fields in my form, which should display the date in differnt format. (yyyy.mm.dd / dd-mm-yyyy)
To get the current date I use java script only
Formular1.p1.date_YYYYmmDD::initialize - (JavaScript, client)
var date = new Date();this.rawValue = date.toLocaleDateString();
My first problem is (red): I get date in English, but I want it in a different language. As it was set in form settings
My second issue is: how can I format a date/time-filed (not a text field) in javascript with a specific pattern on init-event?
It seems my code in init-event overrides the pattern configuration of the date/time-field
Here is my form, if anyone want to check it:
https://acrobat.com/#d=zeOMyj9MhBdYbVWk8S1pHw
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
I think both problems are the same, when setting a date/time field using the rawValue the format always has to be yyyy-mm-dd, if you use any other format the value is just treated as text and displayed without formatting.
var date = new Date();
this.rawValue = util.printd("yyyy-mm-dd", date);
You can also set the formattedValue if you have a date in the correct format.
var date = new Date();
var currentLocale = xfa.resolveNode("#localeSet.#locale").name;
var dateFormat = "date("+currentLocale+"){DD MMM, YYYY}"
this.formattedValue = util.printd(dateFormat, date, true)
This code assumes the display pattern is date{DD MMM, YYYY}
The date format specification is in the XFA Spec http://partners.adobe.com/public/developer/xml/index_arch.html
Regards
Bruce
Views
Replies
Total Likes
Hi,
I think both problems are the same, when setting a date/time field using the rawValue the format always has to be yyyy-mm-dd, if you use any other format the value is just treated as text and displayed without formatting.
var date = new Date();
this.rawValue = util.printd("yyyy-mm-dd", date);
You can also set the formattedValue if you have a date in the correct format.
var date = new Date();
var currentLocale = xfa.resolveNode("#localeSet.#locale").name;
var dateFormat = "date("+currentLocale+"){DD MMM, YYYY}"
this.formattedValue = util.printd(dateFormat, date, true)
This code assumes the display pattern is date{DD MMM, YYYY}
The date format specification is in the XFA Spec http://partners.adobe.com/public/developer/xml/index_arch.html
Regards
Bruce
Views
Replies
Total Likes
perfect!
thank you
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies