1 Reply Latest reply on Oct 4, 2009 11:57 AM by gkaiseril

    Convert Data From One Date Format To Another Date Format

    Jim MacD Level 1

      I’m trying to convert a date field (Text1-29), which is formatted as ‘yyyy/mm/dd’, and move it to data to another field (Text-DOB), which is formatted as ‘mmmm dd, yyyy’.


      I’ve tried various methods, such as the following but with no success. Any suggestions?


      getField("Text-DOB").value = util.scand("mmmm dd, yyyy", (getField("Text1-29").value);

        • 1. Re: Convert Data From One Date Format To Another Date Format
          gkaiseril MVP & Adobe Community Professional

          To reformat a date string, one must first convert the date string into a JavaScript date object, and then format that date object as needed.


          console.show(); console.clear();
          // clear result field by default
          event.value = '';
          // get input date string
          var sText1_29 = this.getField('Text1-29').value;
          // process if there is data
          if (sText1_29.toString() != '') {
          console.println('sText1_29: ' + sText1_29);
          // convert to JavaScript Date object
          var oText1_29 = util.scand('yyyy/mm/dd', sText1_29);
          console.println('oText1_29: ' + oText1_29);
          // convert JS date object to new format
          var sDOB = util.printd('mmmm dd, yyyy', oText1_29);
          console.println('sDOB: ' + sDOB);
          event.value = sDOB;