Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    68
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Display correct time & date for "gmdate"

    http://www.mujak.com/test/test3.php
    I am Mountain Standard Time(MST), Phoenix Arizona but how do I display the correct time~??

    As you can see in the "posts" cell the time is incorrect. The last post displays 5:47pm when its 10:47am. Its 7 hours ahead. How do I fix this~??

    PHP Code:
    <div style="position:relative;left:10px;">

    <?php
    $con 
    mysql_connect("mujak.com","rootkbc1_muser","******");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    mysql_select_db("rootkbc1_halo2x"$con);

    $result mysql_query("SELECT * FROM mybb_posts LEFT JOIN mybb_userfields ON (mybb_posts.uid = mybb_userfields.ufid) WHERE fid=42 ORDER BY pid DESC LIMIT 0,3");

    echo 
    "<center><table border=1 bgcolor=white>
    <tr>
    <th><h3>Subject</h3></th>
    <th><h3>Posts</h3></th>
    <th><h3>Username</h3></th>
    <th bgcolor=#C0CFFA><h1>XBC</h1></th>
    <th bgcolor=#C9FFC2><h1>XLK</h1></th>
    <th><h3>Team</h3></th>
    <th><h3>Console</h3></th>
    <th><h3>Location</h3></th>
    <th><h3>Bandwidth</h3></th>
    </tr>"
    ;

    while(
    $row mysql_fetch_array($result))
      {
      echo 
    "<tr>";
      echo 
    "<td style='-moz-border-radius:9px;padding:5px;'bgcolor=#9CDCFF><b>" $row['subject'] . "</b></td>";
      echo 
    "<td style='-moz-border-radius:9px;padding:5px;font-size:10px;'bgcolor=#C9ECFF>" gmdate("D F j, Y, g:i a"$row['dateline']) . "<br>" $row['message'] . "</td>";
      echo 
    "<td bgcolor=#C9ECFF>" $row['username'] . "</td>";
      echo 
    "<td bgcolor=#C0CFFA>" $row['fid5'] . "</td>";
      echo 
    "<td bgcolor=#C9FFC2>" $row['fid6'] . "</td>";
      echo 
    "<td bgcolor=#C9ECFF>" $row['fid9'] . "</td>";
      echo 
    "<td bgcolor=#C9ECFF>" $row['fid7'] . "</td>";
      echo 
    "<td bgcolor=#C9ECFF>" $row['fid1'] . "</td>";
      echo 
    "<td bgcolor=#C9ECFF>" $row['fid8'] . "</td>";
      echo 
    "</tr>";
      }
    echo 
    "</table>";

    mysql_close($con)
    ?>
    </div>

  • #2
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Try this

    PHP Code:
    <?php
    date_default_timezone_set
    ('MST');
    ?>
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #3
    New Coder
    Join Date
    Jun 2010
    Posts
    68
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Okay I put it like this:
    PHP Code:
      echo "<td style='-moz-border-radius:9px;padding:5px;font-size:10px;'bgcolor=#C9ECFF>" date_default_timezone_set('MST') . gmdate("D F j, Y, g:i a"$row['dateline']) . "<br>" $row['message'] . "</td>"
    Is this correct~?? If it is, it didn't work. You can check the page now. It came out the same, last post was 6:30pm when it is 11:30am.

  • #4
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    the default timezone is used to set the php date time funcyion to call the right time so it should go at the top of the page in order for the zone to be set over the whole file.
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #5
    New Coder
    Join Date
    Jun 2010
    Posts
    68
    Thanks
    1
    Thanked 0 Times in 0 Posts
    thats weird its not working

  • #6
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Take a look here http://www.php.net/manual/en/timezones.php and find the timezone you want.
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P


  •  

    Posting Permissions

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