How do I change the format of the date?

iForm date format javascript

To change the format of the date captured by iFormBuilder using JavaScript, please follow the instructions below.

PLEASE NOTE: In the example below we will be changing the format to MMDDYYYY.

STEP 1: On the Form Properties page of your form, place the following in the Page Level JavaScript section and click Save Changes.

Date.prototype.yyyymmdd = function() {
var yyyy = this.getFullYear().toString();
var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based
var dd = this.getDate().toString();
return (mm[1]?mm:"0"+mm[0]) + (dd[1]?dd:"0"+dd[0]) + yyyy; // padding

d = new Date();

iForm date format javascript

*The d in "d = new Date();" can be any text you would like.  We will be referencing the element with this in the form field. 

STEP 2: Add a Text or Read-Only element to your form.

iForm date format javascript

STEP 3: In the Dynamic Value field of the Text or Read-Only element, put: d.yyyymmdd().  This will call the Page Level JS you created in Step 1.

iForm date format javascript

STEP 4: Test it on your device.

iForm date format javascript

IFORM TIP: If you want to change the format of the order, update the order in this portion of the Page Level JavaScript: "return (mm[1]?mm:"0"+mm[0]) + (dd[1]?dd:"0"+dd[0]) + yyyy; // padding"

    Was this article helpful?
    0 out of 0 found this helpful
    Have more questions? Submit a request


Powered by Zendesk