3 Replies Latest reply on Nov 24, 2012 3:03 PM by Ned Murphy

    AS2: Convert a full date into a numeric string

    Germaris Level 1

      Hi there!

       

      Example:

      2012 11 24  14:25:42  to  20121124142542

      (and not 2128 !!!!!) 

       

      ;-)

       

      How can I do it?

       

      Many thanks in advance for your replies.

        • 1. Re: AS2: Convert a full date into a numeric string
          Ned Murphy Adobe Community Professional & MVP

          If you cast each number as a String you can add them together as a String...

           

          trace(String(2012)+String(11)+String(24)+String(14)+String(25)+String(42));

          • 2. Re: AS2: Convert a full date into a numeric string
            Germaris Level 1

            Thank you Ned!

            Very good and useful...

             

            May I ask you another question, a Date related too?

             

            Well, there is my problem:

             

            My Code:

             

            function howlong(arg) {

                if (length(arg) == 1) {

                    arg = "0" + arg;

                    return arg;

                }

                else {

                    arg = arg;

                    return arg;

                }

            }

            mySessionDate = new Date();

            year= mySessionDate.getFullYear();

            month= mySessionDate.getMonth();

            today= mySessionDate.getDate();

            hour= howlong(String(mySessionDate.getHours()));

            minutes = howlong(String(mySessionDate.getMinutes()));

            seconds = howlong(String(mySessionDate.getSeconds()));

            sessionDateOpening = (year + " " + month + " " + today + " - " + hour + ":" + minutes + ":" + seconds);

            sessionDateOpeningFld.text = sessionDateOpening;

             

            Why is Flash displaying everything fine except the month?

            It shows 10 instead of 11 for the current month !!!?????

            Never encountered such a bug...

             

            :-(

            • 3. Re: AS2: Convert a full date into a numeric string
              Ned Murphy Adobe Community Professional & MVP

              You're welcome.

               

              I answered your followup in your other thread.