Skip navigation
Currently Being Moderated

Digital Clock Time is not display present time

May 18, 2012 3:17 AM

Dear all i have one doubt, i want to confirm please chek my clock time is not display properly what is the problem with this coding

http://www.newtonclients.com/clock/TEST2.html

Please help

 
Replies
  • Currently Being Moderated
    May 18, 2012 6:21 AM   in reply to manojb05

    You haven't shown any coding, so there's no telling how to rectify it.

     
    |
    Mark as:
  • Currently Being Moderated
    May 18, 2012 6:40 AM   in reply to manojb05

    That code has nothing to do with the time that are showing.  That is your html page code.

     
    |
    Mark as:
  • Currently Being Moderated
    May 18, 2012 7:02 AM   in reply to Ned Murphy

    It does have a FlashVar param though:

     

    value="time_var=2:18:33.5156250&clkCol=0xFFFFFF"

     

    Are you derriving that from a server-side script? If so the local time on the server that's being passed is what you need to consider. Perhaps you live in one timezone and expect it to be your time but your webserver is located in another timezone. You'll need to know where the server is that's generating it in order to properly control all the clocks.

     
    |
    Mark as:
  • Currently Being Moderated
    May 18, 2012 7:57 AM   in reply to manojb05

    Your first problem is the "new Date()" will run client-side and get the current time from the users computer. Their time could be wrong. That's why I thought you were passing in a value from your server.

     

    The second problem is, you don't know where in the world this user is. So unless they select their location from a drop-down or similar you'll never have any idea on how to set all the other clocks based on what the users computer tells you for a time. They could be in London or New York. You need to know. Getting the time from the server helps you overcome that because you can base your current time on a fixed location (whereever the server is).

     

    Are you able to get the date from your server?

     
    |
    Mark as:
  • Currently Being Moderated
    May 18, 2012 8:12 AM   in reply to manojb05

    If you have access to PHP you could create a script that will return the value of the current server time, this would be to

    <?PHP
       echo getdate ();
    ?>

    bring this data to Flash using URLLoader

    then converts the data to a Date type to which you can subtract or add hours.

    Of course it is also possible get the server time zone with PHP

     
    |
    Mark as:
  • Currently Being Moderated
    May 18, 2012 8:23 AM   in reply to esdebon

    I was under the impression as I mentioned above that you were doing this because you pass in FlashVars:

     

    <param name="FlashVars" value="time_var=02:18:33.5156250&clkCol=0xFFFFFF" />

     

    In fact all of your clocks have this being sent to them and the values are different for each clock. However on page refresh the values are not updated, so they appear to be hardcoded directly into the HTML.

     

    As long as your web server is set up correctly and has the correct time for its location this should be pretty easy. You'll read that data being sent back in Flash and then use it in the constructor of new Date() which lets you supply it a date. This shows you the structure of the string to send to the date object to create a certain date:

     

    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Dat e.html#Date()

     
    |
    Mark as:
  • Currently Being Moderated
    May 20, 2012 9:48 AM   in reply to manojb05

    Do you have access to PHP on your server?

     
    |
    Mark as:
  • Currently Being Moderated
    May 20, 2012 10:01 AM   in reply to manojb05

    The link above about the Date object shows you the way it can accept a formatted string as a date. You'd need to pass something that conforms to that spec.

     

    Here's the spec I'd use (example from the link above): Tue Feb 1 2005 12:00:00 AM

     

    In PHP to produce that string you'd do this:

     

    <param name="FlashVars" value="time_var=<?php print urlencode(date("D M j Y h:i:s A")); ?>;&clkCol=0xFFFFFF"/>

     

    You should have a variable named "time_var" available inside Flash as a global at that point with the current server time. Try tracing it:

     

    trace(time_var);

     
    |
    Mark as:
  • Currently Being Moderated
    May 20, 2012 12:54 PM   in reply to manojb05

    I just posted above what you'd need to do to the settings, so they would result in this:

    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#ve rsion=9,0,0,0" width="36" height="36" id="SFO" align="middle">

              <param name="allowScriptAccess" value="sameDomain" />

              <param name="allowFullScreen" value="false" />

              <param name="movie" value="analog_clock.swf" />

              <param name="FlashVars" value="time_var=<?php print urlencode(date("D M j Y h:i:s A")); ?>;&clkCol=0xFFFFFF"/>

              <param name="quality" value="high" />

              <param name="bgcolor" value="#ffffff" />

              <param name="wmode" value="transparent">

              <embed src="analog_clock.swf" width="36" height="36" align="middle" flashvars="time_var=<?php print urlencode(date("D M j Y h:i:s A")); ?>&clkCol=0xFFFFFF"

                quality="high" bgcolor="0xFFFFFF" name="analog_clock" allowscriptaccess="sameDomain"

                allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"

                wmode="transparent" />

    </object>

     

     

    The server would need to know PHP code is on the page so the page should have the file extension .php, e.g. index.php.

     

    Then it would be up to you inside Flash to take time_var and convert it to the correct time you need for any specific location based on knowing the servers location.

     

    When you create the date inside Flash you'd use the var like so:

     

    var time = new Date(time_var); // creates a date based on what the server sent.

     

    The rest you can figure out I'm sure. Add/subtract hours to hourHand when you get the hour to adjust it appropriately.

     

    Watch out for wrapping hours, such as adding 5 hours to 22 hours makes 27 hours and obviously that's incorrect. You'll need to adjust it to 3am the next day. Same in reverse. Don't subtract 10 hours from 5am or it's 7pm the previous day. Adjust to needs.

     
    |
    Mark as:
  • Currently Being Moderated
    May 21, 2012 6:54 AM   in reply to manojb05

    The approach looks fine although you could have passed it back in a single variable like I did in my code above which would be accepted by the ActionScript3 Date object. When you pass the Date() constructor a time like new Date(time_var) then all the methods like getHours() will use the date you supplied, not the current date. But your method of breaking up the time into a bunch of vars should work fine too, just a lot more work.

     

    To make a clock for another region, as I've said many times, you just need to know where the server is that is hosting time.php. Then you need to add or subtract from the time that server returns to calculate other places like NY, USA as mentioned.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points