Forum Moderators: coopster

Message Too Old, No Replies

Timestamp change from MySQL database

I need to know how to change the timezone from a timestamp

         

Aschx

2:36 am on Oct 5, 2007 (gmt 0)

10+ Year Member



ok I need a code that will allow me to change my timestamp back 4 hours from what it currently is. The format of the timestamp is: yyyy-mm-dd hh:mm:ss this is my current code to show my shouts:

$linkID = mysql_connect($host,$user,$pass) or die ("Could not connect to host.");
mysql_select_db($database,$linkID) or die ("Could not find database.");

$query = "SELECT * from shoutbox ORDER BY id DESC";
$resultID = mysql_query($query,$linkID) or die ("Data not found");

$xml_output = "<?xml version =\"1.0\"?>\n";
$xml_output = "<shouts>\n";

for ($x = 0; $x < mysql_num_rows($resultID); $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= "\t<shout>\n";
$xml_output .= "\t\t<name>" . $row['name'] . "</name>\n";
$xml_output .= "\t\t<time>" . $row['time'] . "</time>\n";
$xml_output .= "\t\t<site>" . $row['site'] . "</site>\n";
$xml_output .= "\t\t<message>" . $row['message'] . "</message>\n";
$xml_output .= "\t</shout>\n";
}
$xml_output.= "</shouts>";

echo $xml_output;

?>

not to mention I have tried to use the following code That DIDNT help:

$date_time1 = strtotime("yyyy-mm-dd hh:ii:ss"); // returns bad value -1 due to DST
$date_time2 = strtotime("yyyy-mm-dd hh:ii:ss EST"); // works great!

jbroder

3:56 am on Oct 5, 2007 (gmt 0)

10+ Year Member



You might try using mysql's built in date/time functions to change the timestamp before it even gets to php.

Hope that helps.