Custom date format for DatePickerWidgetAnnotation

Hi there,

I am using the DatePickerWidgetAnnotation to allow users to fill a date into a PDF form. I am wondering how I can change the date format from the current mm/dd/yy - specifically I need yyyy-mm-dd.

Thanks, Luke.

Hey there,

Are you creating the DatePicker programmatically? Or is it already part of the document?

Thanks,
Logan

Hi,

I am creating them programmatically, roughly like this:

const field = new Annotations.Forms.Field(fieldItem.Id, {
    value: fieldItem.Value // some value
});
const annot = new Annotations.DatePickerWidgetAnnotation(field);

// ... apply page/width/height/x/y here ...

 annotManager.addAnnotation(annot);
 annotManager.redrawAnnotation(annot);

Cheers, Luke.

Hey there!

When you’re creating the field, try using these settings (and update the date formats to your linking):

const field = new Annotations.Forms.Field(
        'DatePicker',
        {
          type: 'Tx',
          value: '1.1.2004',
          // Actions need to be added for DatePickerWidgetAnnotation to recognize this field.
          actions: {
            F: [
              {
                name: 'JavaScript',
                // You can customize the date format here between the two double-quotation marks
                // or leave this blank to use the default format
                javascript: 'AFDate_KeystrokeEx("mmm d, yyyy");',
              },
            ],
            K: [
              {
                name: 'JavaScript',
                // You can customize the date format here between the two double-quotation marks
                // or leave this blank to use the default format
                javascript: 'AFDate_KeystrokeEx("mmm d, yyyy");',
              },
            ],
            
          },
        },
      );

Let me know if this doesn’t work for you.

Thanks Logan, that has worked.

1 Like