Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2009
    Posts
    33

    GMT or Time zone Help

    Hi, everyone. I was hoping someone have any suggestions for solving a problem.

    I have a web object that will show a live media stream at a specific time each week. I need to be able to get the user's time (which could be any time zone) and tell them either:

    1. The stream will start in HH:MM:SS based on the set time (12 noon CT), and it needs to be specific to their time zone
    or
    2. If the stream has started at the set time (12 noon CT), and if they arrive 15 minutes or more after, they can't watch and the app exits...

    Any help would be appreciated...on a time crunch (pun intended)

  2. #2
    Join Date
    Mar 2009
    Location
    -31.9554,115.85859
    Posts
    282
    Firstly, to determine their current locale (timezone) you can pull this information from the registry, located here (On XP)

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\TimeZoneInformation

    That information will give you the standard name and the daylight name (for daylight sayings if you need it. Also there is a 'flag' which will tell you whether or not you need to apply it. See here for information on the fields listed.
    • Bias- Negative offset from GMT in minutes.
    • StandardName - Standard name of this time zone.
    • StandardBias - Offset applied to Bias for Standard Time.
    • StandardStart - A coded year, month, day of week, week, hour, minute, second, and millisecond of when the switch to Stand Time occurs. This is detailed at the end of the tip.
    • DaylightName - Standard name for Daylight time.
    • DaylightBias - Offset applied to StandardBias wich is applied toBias for Daylight Time.
    • DaylightStart - A coded year, month, day of week, week, hour, minute, second, and millisecond of when the switch to Daylight Time occurs. This is detailed at the end of the tip.
    • ActiveTimeBias - The currently active offset from GMT.

    Using the information from there, I would then look for the Display from this registry location.

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\TIMEZONE

    Then basically do the math...

    Hope that helps

  3. #3
    Join Date
    May 2007
    Location
    Sydney, Australia
    Posts
    1,546
    Here's a simple example to pull the StandardName TimeZone from the registry, together with the user's Sytem-Time :

    Time & TimeZone Example

    As boku says, just do the math from there.

    ... or you could even use Javascript in a WebObject, and then read the resulting html into string:

    Javascript:
    Code:
    <script type="text/javascript">
    var x = new Date()
    var timeZone = currentTimeZoneOffsetInHours = x.getTimezoneOffset()/60   
    document.write('Timezone is: ' +  timeZone);
    </script>
    The Javascript will return a number (from -12 to +12, equating to the user's TimeZone location. Personally, I think the AMS Reg.GetValue method is easiest. The Javascript method is kind of going about things the long way.

  4. #4
    Join Date
    Jun 2009
    Posts
    33

    Thanks- I'll give it a shot

    Thank you...I'll give it a shot...

  5. #5
    Join Date
    Jun 2009
    Posts
    33
    OK...this seems like it should be simple, but it's proving not to be...

    on a multi-OS environment (XP, VISTA, '07), i want to be able to say

    "This is the current UTC or GMT time and the live stream will start in x minutes (based on UTC-6/Central US Time)" and have it adjust for DST.

    The first example isn't working on Vista. I haven't tried the server-based example...can't even wrap my mind around it. I'm not a noob, but not an expert. I appreciate all the help so far...and will REALLY appreciate the help that solves this issue.

  6. #6
    Join Date
    Jun 2009
    Posts
    33

    This should work, right?

    Since I'm using a web object and my server is always located in the same time zone (EST), i cold load a page with this script into the Web Object first with a note that the stream starts at 12 Noon Central, and then redirect 2 minutes early to the web page with the stream, but not redirect if they enter 20 minutes late.

    If any PHP gurus have any suggestions, they would be most welcomed and appreciated:
    Code:
    <?php 
     $day = date("D");   //returns "Wed"
     $time = date("Hi"); //returns HoursMinutes
     if( ($day == "Wed" && $time >= "1258" && $time < "1320") ||
         )
     {
      header("Location: XXXXXX");
      exit;
     }
    ?>

  7. #7
    Join Date
    Jun 2009
    Posts
    33

    Figured it out

    Since I was suing a web object in AMS, I decided to do this with a PHP script. Works great - tested a few times today. I set up an auto refresh at 10 second intervals so no one is waiting too long at the designated time. If anyone wants the final code, here it is. Remember that it pulls the server's time, not the user's. This is handy for my application.

    Code:
    <?php
    $hour = date('G');
    $minute = date('i');
    $day = date('w');
    $m = $hour * 60 + $minute; // Minutes since midnight.
    if ($day == 3 && $m >= 778 && $m <= 796) 
    header("Location: http://your_site_here.com");
    ?>
    
    <html>
    <head>
    <meta **********="refresh" content="10" /> 
    </head>
    <body>
    <p style="max-width:320px;">
    <font face="Arial" color="#000000"><center><strong>Text, image or whatever here.
    </body>
    </strong></center></font>
    </body>
    </html>
    Again...thanks for everyone for the inspiration and continued help! Now just need to figure out ONE MORE THING. Probably do it by checking which URL is loaded...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts