1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

It's 5 o'clock somewhere (script)

Discussion in 'PHP & Perl' started by GuinnessMan, May 8, 2012.

  1. GuinnessMan

    GuinnessMan Junior Member

    Joined:
    Apr 4, 2009
    Messages:
    120
    Likes Received:
    90
    Occupation:
    Co-Founder - Various; Independent DSA Closeout Con
    Location:
    USA
    I am putting together a sort of hobby site (built on WordPress) for a colleague of mine and wanted to draw attention to his heavy advocacy for the legalization of marijuana. He asked me if there was a way one could create a script that would update regularly to show where it is 4:20. For example, at 4:20 PST the web script would output text saying, it's 4:20 in Los Angeles.

    Any assistance on this would be great!
     
  2. partymarty4870

    partymarty4870 Elite Member

    Joined:
    Jul 7, 2010
    Messages:
    2,034
    Likes Received:
    1,690
    Location:
    I come from a land downunder
    there's a beer site out there somehwere that does exactly that - and I remember it from years ago, so it should be pretty easy.

    But sorry, thats all the help I can give
     
  3. GuinnessMan

    GuinnessMan Junior Member

    Joined:
    Apr 4, 2009
    Messages:
    120
    Likes Received:
    90
    Occupation:
    Co-Founder - Various; Independent DSA Closeout Con
    Location:
    USA
    Thank you! At least it's confirmed. I'm doing my best...so far just getting lyrics and etymology.
     
  4. bigwhite

    bigwhite Regular Member

    Joined:
    Sep 27, 2011
    Messages:
    473
    Likes Received:
    54
    When that site goes live, let me know :D
     
  5. myownhero

    myownhero Power Member Premium Member

    Joined:
    Mar 13, 2012
    Messages:
    763
    Likes Received:
    713
    Occupation:
    SEO Analyst / Link Builder
    Location:
    United States
    Home Page:
    50 minutes till 4:20

    I can't wait that long, man.
     
  6. Nigel Farage

    Nigel Farage BANNED BANNED

    Joined:
    Feb 8, 2012
    Messages:
    563
    Likes Received:
    1,495
    You could do an email blast daily at 4:20 (time zone specific) that offers special deals on pot-related products & services, or does updates on the State of Marijuanadom, such as pending legislation. Also, "joke" emails where businesses (local grocery stores) claim to have specials "Albertson's 4:20 special: 3-liter bottle of Mountain Dew + 32 oz. bag of Doritos for $4.20, today only"

    Sports corner that only features highlights of players that have the number "4", or the number "20" on their jersey. Obviously, April 20th is a big day.

    Start developing a list of music that has direct reference to pot, for use in your in-house advertising.
     
    • Thanks Thanks x 1
    Last edited: May 9, 2012
  7. tripper_john_md

    tripper_john_md Newbie

    Joined:
    Feb 21, 2011
    Messages:
    40
    Likes Received:
    35
    Location:
    Southern Germany
    I have no experience with marijuana and I don't know if I read this post right, but this script should do what I thought was asked for. It displays a random place where the local time is the nearest to the given time. Hope this makes sense, I'm a little bit tired. :)
    It makes use of php's date/time functions.
    PHP:
    <?php
    $time 
    '1:00pm'//format hh:mm - either 24h or 12h - pm/am gets converted to 24h-format
    $origin_timezone 'PST';

    //dummy to get one of origin_timezone's identifiers
    $tz = new DateTimeZone('Europe/London');
    $arr $tz->listAbbreviations(); //we'll use this again later

    //get origin_timezone's offset
    $tz = new DateTimeZone($arr[strtolower($origin_timezone)][0]['timezone_id']);
    $offset $tz->getOffset(new DateTime());

    //get time in seconds
    $seconds explode(':',$time);
    $seconds = ($seconds[0]+(strpos($time,'pm') ? 12 0))*3600+(int)$seconds[1]*60;  

    //get origin_timezone's current time
    $tz_seconds = new DateTime(null,$tz);
    $tz_seconds $tz_seconds->format('H:i');
    $tz_seconds explode(':',$tz_seconds);
    $tz_seconds $tz_seconds[0]*3600+(int)$tz_seconds[1]*60;

    //get difference and mathematically nearest target tz offset
    $diff $tz_seconds-$seconds-3600;
    $target_tz $offset-($diff%3600>1800 $diff+$diff%3600 $diff-$diff%3600);

    //get identifier for nearest target tz
    //$a contains timezone's abbreviation, $b contains array with timezone_ids
    $ids=array();
    foreach(
    $arr as $a  => $b){
        
    //echo $b[0]['offset'];echo '<br>';
        
    foreach($b as $c)
        if (
    $c['offset'] == $target_tz && strlen($c['timezone_id'])>4){
            
    //store each random timezone_id
            
    $ids[]=$c['timezone_id'];
        }
    }

    //display random timezone_id
    echo 'It soon will be (or was not long ago or is currently) '.$time.' in '.$ids[array_rand($ids)];
    ?>
    I'm not sure if it could've been done in an easier way, it's my first draft. At least it should give some ideas. :)
     
    • Thanks Thanks x 2
  8. LakeForest

    LakeForest Supreme Member

    Joined:
    Nov 11, 2009
    Messages:
    1,269
    Likes Received:
    1,802
    Location:
    Location Location
    Hell yes great idea.



    In regards to the It's 5 o'clock somewhere cliche...That's for drinking right?

    ...I always used noon...Or, you know, after breakfast...
     
  9. bigwhite

    bigwhite Regular Member

    Joined:
    Sep 27, 2011
    Messages:
    473
    Likes Received:
    54
    Quite the mind you have. Great ideas!
     
  10. Nigel Farage

    Nigel Farage BANNED BANNED

    Joined:
    Feb 8, 2012
    Messages:
    563
    Likes Received:
    1,495
    Here's another one:
    Hire someone to write an app for iPhone, and every day it goes off at 4:20 with the sound...

    BONG! BONG! BONG!

    Okay, so maybe that one was dumb, but this one's not:

    You need a mascot, like the Geico Gecko. Maybe a mouse, like Speedy Gonzalez, only REAL S~L~O~W. He talks slow, and moves slow and the first thing he does when anyone new shows up is passes the blunt. Then they slow down too, roflmao. He can be a spin-off of "Smokey the Bear" only his name is "Tokie". One day the Geico Gecko shows up with his obnoxious British/Australian accent and starts going on about car insurance, and Tokie passes him the blunt.

    Suddenly, the Gecko sounds just like Cheech Marin from "Up in Smoke" or that surfer dude on "Fast Times at Ridgemont High".

    Then, Geico (the real company) issues a C & D, which makes nice publicity for the web-site. You can claim "Fair Use" because it's a parody.
     
  11. GuinnessMan

    GuinnessMan Junior Member

    Joined:
    Apr 4, 2009
    Messages:
    120
    Likes Received:
    90
    Occupation:
    Co-Founder - Various; Independent DSA Closeout Con
    Location:
    USA
    Wow...you are a beautiful man! Thanks and Rep given.
     
  12. viralmoney

    viralmoney Junior Member

    Joined:
    Jun 19, 2009
    Messages:
    163
    Likes Received:
    242
    Home Page:
    I don't know people drink beer at 5 of clock. I drink when I damn well feel like it. My liver can't tell time.:drinking2