View Full Version : Display correct time & date for "gmdate"

06-19-2010, 07:55 PM
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~??

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

$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>
<th bgcolor=#C0CFFA><h1>XBC</h1></th>
<th bgcolor=#C9FFC2><h1>XLK</h1></th>

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>";


06-19-2010, 08:01 PM
Try this


06-19-2010, 08:32 PM
Okay I put it like this:

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.

06-20-2010, 12:43 AM
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.

06-20-2010, 01:17 AM
thats weird its not working

06-20-2010, 11:56 AM
Take a look here http://www.php.net/manual/en/timezones.php and find the timezone you want.