Results 1 to 2 of 2

Thread: It's 5:00 Somewhere

  1. #1
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default It's 5:00 Somewhere

    1) CODE TITLE: Where's it 5:00 PM?

    2) AUTHOR NAME/NOTES:

    3) DESCRIPTION: Shows where in the world it is currently 5:00pm

    4) URL TO CODE:

    or, ATTACHED BELOW (see #3 in guidelines below):

    PHP Code:
    <?php
    for ($zone 0$zone <24$zone++) {
        if (
    $zone 12) { 
            
    // east right (Europe) 
            
    $symbol "+";
            
    $minus 0;
        } else {
            
    // west left (Americas)
            
    $symbol "-";
            
    $minus 12;
        }
        
    date_default_timezone_set('Etc/GMT' $symbol . ($zone $minus));
        
    $hours date('G'); // current time in the zone
        
    if ($hours == 17) {
            
    date_default_timezone_set('Etc/GMT+0');
            
    $gmt date('G'); // time in green which long 0 
                
    while ($gmt != $hours ) {
                    if (
    $zone 12) {
                        
    // west left (Americas)
                        
    $gmt--;
                        
    $long $long 15;
                    } else {
                        
    // east right (Europe) 
                        
    $long $long 15;
                        
    $gmt++;
                    }
                }
            if (
    $zone 12)
                
    $long =  '-' $long;
        }
    }
    ?>
    <!DOCTYPE html>
    <html>
        <head>
            <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
            <style type="text/css">
                html { height: 100% }
                body { height: 100%; margin: 0; padding: 0 }
                #map_canvas { height: 100% }
            </style>
            <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
            <script type="text/javascript">
            function initialize() {
                var latlng = new google.maps.LatLng(42, <?php echo $long;?>);
                var myOptions = {
                    zoom: 2,
                    center: latlng,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };
                var map = new google.maps.Map(document.getElementById("map_canvas"),
                    myOptions);
                var marker = new google.maps.Marker({
                    position: latlng, 
                    map: map, 
                    title:"It's 5 PM Here!"
                });
            }
        </script>
    </head>
    <body onLoad="initialize()">
      <div id="map_canvas" style="width:100%; height:100%"></div>
    </body>
    </html>
    Corrections to my coding/thoughts welcome.

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    I did part of this wrong, it goes into a loop if it's on the eastern side, will adjust...
    Corrections to my coding/thoughts welcome.

Bookmarks

Posting Permissions

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