Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2004
    Location
    Sawley
    Posts
    771
    Tokens
    1,631
    Habbo
    T0X!C-uk

    Latest Awards:

    Default PHP Tutorial 1: Grab Local Date And Time

    Ok over the next week or so i will be adding some php tutorials as i have been asked a few times to help people learn.
    As i dont have the time i cannot go around teaching people individually it wouldnt be possible. So i have a wrote a few tutorials that you can all use. If you read though them properly it will give you the basic idea of how php works and hopefully you will be able to learn bigger things in the future.

    Hopefully all these will get moved and stickied into the websites tutorials thread :8

    Tutorial 1: Grab Local Date And Time.

    OK, just run this as filename.php?timezone_local=8 to get the local time
    this could be handy if your host changes their local time on the server then you wont have any problems when they do.

    If you are going to use this in a cms you will need to set $timezone_local to your timezone instead of the $_GET[] variable.

    If your timezone is something like +9:30 you will need to set $timezone_local to 9.5

    Code:
    <?
    $timezone_local = $_GET['timezone_local'];
    $time = time();
    $timezone_offset = date("Z");
    $timezone_add = round($timezone_local*60*60);
    $time = round($time-$timezone_offset+$timezone_add);
    $date = date("l dS of F Y h:i:s A", $time);
    echo $date;
    ?>

  2. #2
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Is it just me or have you gone in to a tutoiral makeing frenzy since the new tutorials forum came in.

    Also none of these are tutorials, there good scripts, but there still justs scripts, no tutorilas "/

  3. #3
    Join Date
    Aug 2004
    Location
    Sawley
    Posts
    771
    Tokens
    1,631
    Habbo
    T0X!C-uk

    Latest Awards:

    Default

    LOL ye i just want to get some tutorials on the new forum :p

    And they are tutorials just not for beginners. Im currently writing one now that explains the basics of php like opening and closing tags, variables etc etc so then people will understand the others more

  4. #4
    Join Date
    Jul 2004
    Location
    Sunshine Coast, Queensland, AU
    Posts
    1,830
    Tokens
    467

    Latest Awards:

    Default

    does any1 have the ip code of the user and how many people are online

  5. #5
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Ip is just $_SERVER['REMOTE_ADDR']

    so to display it

    PHP Code:
    echo $_SERVER['REMOTE_ADDR'] ; 
    Athogh users online is a little more complex, so its easyer just to download a script for it form somewhere

  6. #6
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    w00t thx mentor i have been looking around for that code for PHP for ages - i cant give u rep as it says i have to spread a bit more around before i can give it to u again :S

  7. #7
    Join Date
    Jul 2004
    Location
    Sunshine Coast, Queensland, AU
    Posts
    1,830
    Tokens
    467

    Latest Awards:

    Default

    mine does shows this
    <?
    echo $_SERVER['REMOTE_ADDR'] ;<br>
    $timezone_local = $_GET['timezone_local'];<br>
    $time = time();<br>
    $timezone_offset = date(&quot;Z&quot;<br>
    $timezone_add = round($timezone_local*60*60);<br>
    $time = round($time-$timezone_offset+$timezone_add);<br>
    $date = date(&quot;l dS of F Y h:i:s A&quot;, $time);<br>

    echo $date;?>

  8. #8
    Join Date
    Aug 2004
    Location
    Sawley
    Posts
    771
    Tokens
    1,631
    Habbo
    T0X!C-uk

    Latest Awards:

    Default

    Quote Originally Posted by phoenix-iv
    mine does shows this
    <?
    echo $_SERVER['REMOTE_ADDR'] ;<br>
    $timezone_local = $_GET['timezone_local'];<br>
    $time = time();<br>
    $timezone_offset = date(&quot;Z&quot;<br>
    $timezone_add = round($timezone_local*60*60);<br>
    $time = round($time-$timezone_offset+$timezone_add);<br>
    $date = date(&quot;l dS of F Y h:i:s A&quot;, $time);<br>

    echo $date;?>
    Yours? i think you will find thats the code i wrote above......

    Also about mentors help you will need to write the code like this
    Code:
    <? echo $_SERVER['REMOTE_ADDR'] ; ?>
    If you have not already opened a PHP tag

  9. #9
    Join Date
    Jul 2004
    Location
    Sunshine Coast, Queensland, AU
    Posts
    1,830
    Tokens
    467

    Latest Awards:

    Default

    but then the page is all blank

Posting Permissions

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