8 Replies Latest reply on Jan 7, 2013 8:15 PM by SEIZMICid

    Retrieve/Place current date-time into text box

    joelstillman

      Hello, I'm wondering if anyone has experimented with dynamically retrieving the computer's current date/time and placing that information into a text box? It seems like a simple enough action, but i can't find any documentation related to this topic. I suspect this method of call and retrieve behavior could be unexpectedly useful in a lot of situations, for a lot of people!

       

      -joel

        • 1. Re: Retrieve/Place current date-time into text box
          [Jongware] Most Valuable Participant

          It depends on what you mean -- exactly. Do you "need" an InDesign document that continuously holds the current date and time? What if you print it? Export to PDF? Send it off to be printed, cut, bound, and sold as a book?

           

          It's extremely easy (really) to get hold of the current date & time at the moment you run a script, and put that into some text frame. "Date" is a base class of Javascript and has everything you'd probably want for that.

           

          On the other hand, if you want ID to automatically and continuously update date and time in some document, you would need a script that continuously keeps running in the background. What a waste of resources that would be -- doesn't your OS have a clock applet you could look to instead?

          1 person found this helpful
          • 2. Re: Retrieve/Place current date-time into text box
            joelstillman Level 1

            Yes, thank you, sincerely, your knowledge of the possibilities has helped me define more precicely what it is i am looking for. The ideal scenario is that the javascript base class Date is activated upon PDF export -- placing the current date into the designated text frames. I do not yet know how to implement this, but this was already helpful as i said, so thanks again.

             

            If anyone would like to share how to enact this script, i, and anyone else reading would be quite privelaged.

             

            -joel

            • 3. Re: Retrieve/Place current date-time into text box
              Steven.. Level 3

              Maybe you can make a menuAction event listener for pdf menu which will update your value.

              1 person found this helpful
              • 4. Re: Retrieve/Place current date-time into text box
                brettpolo Level 1

                You don't need a script to do this.  Under the Type menu, there is a 'Text Variables...' submenu.  This will let you define text variables, and place them into text boxes.  There is a preset variable called 'Output Date', which will display the current date (MM/dd/yy) when a PDF is output.  If you want to display the time as well, under 'Text Variables...', go to 'Define...', and you can define your own.  Under 'Type', select output date, and add any variable data you want.  The format for time and date should look something like this:

                 

                hh:mm:ss MM/dd/yy

                 

                I've found that Text Variables don't update in the display very consistantly, but I just tested this, and regardless of the displayed value, the output PDF has the correct time and date.

                 

                If you want to control text variables with javaScript, check out the TextVariable(s) and TextVariableInstance(s) classes.

                 

                As a side note, text variables work fine if you want date/time, page, etc, but I really wish they would add a bit more functionality, especialy with things like seperation name, color profile, and PDF output profile.  It would be a huge timesaver to have all of this type of metadata be easily inserted.

                • 5. Re: Retrieve/Place current date-time into text box
                  [Jongware] Most Valuable Participant

                  Now why didn't I think of that ...

                   

                  date.png

                   

                  Top entry is the Date Class. Bottom entry controls variables. I must have developed a blind spot when I read "script" ...

                  • 6. Re: Retrieve/Place current date-time into text box
                    Steven.. Level 3

                    oops, I never realized that option.

                     

                    Now thats a problem of thinking tooo much

                    • 7. Re: Retrieve/Place current date-time into text box
                      joelstillman Level 1

                      It's working perfectly! and it is extraordinarily customizable. Stunning.

                       

                      That's an excellent point, though, about the potential for more metadata inclusion.

                      Once you get a taste, it's easy to want more i suppose.

                       

                      Regardless, thank you very much, and it seems that others were helped by your response in addition to myself, which makes this process all the more worthwhile. And thanks to everyone else who participated in the conversation.

                       

                      -joel

                      • 8. Re: Retrieve/Place current date-time into text box
                        SEIZMICid

                        If you change the variable to "Modification Date" from "Output Date" it looks likt it displays correctly. This is a new trick to me so maybe I'm missing something. Thanks for the help all!