3 Replies Latest reply on Feb 8, 2011 1:10 PM by Ned Murphy

    getTimer()

    Ron Colmen Level 2

      Does the getTimer function affect the output time? so it's seen different in each country?

       

      I've created adigital clock using the time received from a php. Customers see a different time than mine. (php file works perfectly and output the time in my timezone).

        • 1. Re: getTimer()
          Ned Murphy Adobe Community Professional & MVP

          The getTimer will only affect the output time (?) if you use it to affect the output time.  Otherwise, the getTimer is unrelated to timezones and is purely related to the milliseconds that have elapsed since the swf started playing.

          • 2. Re: getTimer()
            Ron Colmen Level 2

            Thanks Ned.

             

            I'm using this code to display the time. But viewers see different times in different countries. What's the cause for this? and how can I fix this?

             

            php

            <?php

            $tz =  new DateTimeZone('Australia/Sydney');

            $date = new DateTime('now', $tz);

            $msgtme =  $date->format('H:i:s');

                $hours = substr($msgtme, 0, -6);

                $minutes = substr($msgtme, 3, -3);

                $seconds = substr($msgtme, -2);

                echo ($hours * 3600 + $minutes * 60 + $seconds);

            ?>

             

            AS

            var tl:MovieClip=this;

            var startTime:Number;

             

            server = new LoadVars();

            server.onData = function (src){

            tl.timeMS = Number(src);

            startTime=getTimer();

            clock_txt.onEnterFrame = timeF;

            };

            server.load("http://www.myweb.com/timeServer.php");

             

            function timeF(){

            var d:Date = new Date(tl.timeMS*1000+getTimer()-startTime);

            if(d.getHours()>12){

            var hours:Number=d.getHours()-12;

            var ampm:String = "PM";

            } else if(d.getHours()==12){

            hours=12;

            ampm="PM"

            } else {

            hours=d.getHours();

            ampm="AM";

            }

            var hoursS:String = formatS(hours.toString());

            var minutes:String = formatS(d.getMinutes().toString());

            var seconds:String = formatS(d.getSeconds().toString());

            _root.clock_txt.clock_txt.text = hoursS + ":" + minutes + ":" + seconds +" "+ ampm;

            }

             

            function formatS(s:String):String{

            while(s.length<2){

            s="0"+s;

            }

            return s;

            }

            • 3. Re: getTimer()
              Ned Murphy Adobe Community Professional & MVP

              My guess would be that your PHP is not returning the time you believe it is.  To get the getTimer wondering out of the picture, remove it and see if different times are still being reported.