Date conversion for fillable PDF

Could anyone advise if there is a simpler way of doing this.

Date field changes format from dd/mm/yyyy to yyyy-mm-dd when using a fillable PDF.

My solution is reformat the input date in a hidden field and use this to populate the PDF. Below is my onClick event script.

Many thanks
Stephen

------------------------------------------------------------------------------

var indate = BO.F_Date.getValue(); // The user's date selection field

var day = indate.getDate();
var month = indate.getMonth()+1;
var year = indate.getFullYear();

BO.F_Conversion.setValue(day + '.' + month + '.' + year); // Hidden string field

------------------------------------------------------------------------------

Hi,

I had a similar issue when converting timestamps from datagrid into PDF... AFAIK you have to use generic JavaScript Date functions to produce desired text input for PDFfill service in a hidden field - exactly what you do.

Much appreciated, many thanks for your input!

Maybe a bit late to the party, but I use this code

BO.F_Date.setValue(new Date().toLocaleDateString("de-DE", { year: "numeric", month: "2-digit", day: "2-digit" }));

in the "onShow" event of a form to set my - hidden - date field to the needed format (which I then use to populate the field in my PDF).

You now could easily replace the locale setting "de-DE" by a variable read from the browser settings, so that it gets written to the PDF in the user's format.

Please note that the "F_Date" field is a simple text field.