4 Replies Latest reply on Mar 4, 2010 6:56 AM by gkaiseril

    UTC Dates


      Is it possible to include a script which would turn a UTC date/time value into a local date/time value when the page is rendered by a PDF reader?

        • 1. Re: UTC Dates
          try67 MVP & Adobe Community Professional

          You can use the util.printd() method to give a Date object any format you


          1 person found this helpful
          • 2. Re: UTC Dates
            gkaiseril MVP & Adobe Community Professional

            The time shown on the PDF Properties window is the UTC creation date object displayed in the local time adjusted for DST as needed of the viewer so you will need to write some code to get the UTC date and time from the date object for the creation date and time.


            // get creation date object
            var oCreationDate = this.info.CreationDate;
            // build the UTC creation string
            var sUTCCreate =(oCreationDate.getUTCMonth() + 1) + '/';
            sUTCCreate += util.printf('%,002d', oCreationDate.getUTCDate()) + '/';
            sUTCCreate += oCreationDate.getUTCFullYear();
            sUTCCreate += ' '+ oCreationDate.getUTCHours() + ':';
            sUTCCreate += util.printf('%,002d', oCreationDate.getUTCMinutes()) + ':';
            sUTCCreate += util.printf('%,002d', oCreationDate.getUTCSeconds()) + '.';
            // message to display
            var sMsg = 'This PDF was created on: '
            sMsg += '\n' + oCreationDate + '\n';
            sMsg += 'Time Zone Offset: ' + (oCreationDate.getTimezoneOffset() / 60) + '\n\n';
            sMsg += 'UTC Creation Date & Time (mm/dd/yyyy HH:MM:ss.): ' + sUTCCreate;
            // display message
            app.alert(sMsg, 2, 0);

            // modification data
            // get modification date object
            this.getField('Mod.Date.Value').value = oModDate
            // build the UTC mod string
            var sUTCMod =(oModDate.getUTCMonth() + 1) + '/';
            sUTCMod += util.printf('%,002d', oModDate.getUTCDate()) + '/';
            sUTCMod += oModDate.getUTCFullYear();
            sUTCMod += ' '+ oModDate.getUTCHours() + ':';
            sUTCMod += util.printf('%,002d', oModDate.getUTCMinutes()) + ':';
            sUTCMod += util.printf('%,002d', oModDate.getUTCSeconds()) + '.';
            // message to display
            sMsg = 'This PDF was modified on: '
            sMsg += '\n' + oModDate + '\n';
            sMsg += 'Time Zone Offset: ' + (oModDate.getTimezoneOffset() / 60) + '\n\n';
            sMsg += 'UTC Modification Date & Time (mm/dd/yyyy HH:MM:ss.): ' + sUTCMod;
            // display message
            app.alert(sMsg, 2, 0);


            If you want to convert an entered date or time string in local time to the UTC date and time, you will need to use the 'util.scand()' method to convert the local date string into a JavaScript object and then use the UTC methods to get the various date and time values from the date object.


            Note that it is important for user of Acrobat/Reader to keep their computer synced to the international time standard and the time zone properly applied because if the computer date is not set properly Extended Rights Enabled forms may not work properly when the time of the computer is before the time the form was created or modified is detected.

            • 3. Re: UTC Dates
              hopsmacker Level 1

              Thanks to both of you for your help.


              I guess my main challenge is that I'm generating PDF reports programmatically (C++/LibHaru). It was interesting to learn that the Acrobat Reader exposes a PDF DOM and accomodates JavaScript.I assume through this mechanism I should be able to achieve our goal:


              Our reports are sent to people via e-mail and we would like to ensure that any dates we include are actually presented adjusted to their time zone.


              I already have the JavaScript code to do the translations. What is missing is a good documentation of the PDF DOM and where JavaScript snippets fit.

              • 4. Re: UTC Dates
                gkaiseril MVP & Adobe Community Professional

                You can find more about the Acrobat API at Acrobat Developer Center. There is an SDK download and a numnber of useful docments there.