Note that there are some explanatory texts on larger screens.

plurals
  1. POconvert date/time from local server time to time zone?
    primarykey
    data
    text
    <p>I am inserting the time and date as a time stamp into my table in a query, and this is showing as the local server time. My local server is in america.</p> <p>I am trying to convert the local time to time zone specific - Europe/London.</p> <p>i am preferably wanting to insert the timezone specific time upon it being inserted into the table, however i have been having a lot of problems with this and everything i do doesn't work.</p> <p>so now im simply trying to convert the time from local to time zone specific when i echo it out. and this gives this error:</p> <pre><code>Catchable fatal error: Object of class DateTime could not be converted to string in /home/content/31/9118831/html/ptbadmin/stats.php on line 79 </code></pre> <p>can someone please show me where im gonig wrong. my table looks like this:</p> <pre><code> session_id | user_ip | session_start| 1 1.1.1.1 2013-04-08 00:15:24 2 1.1.1.1 2013-04-08 00:15:24 </code></pre> <p>here is my code:</p> <pre><code> $sql = "INSERT INTO ptb_sessions (session_id, user_ip, session_start, session_end) VALUES (NULL, '" . $_SERVER['REMOTE_ADDR'] . "', UTC_TIMESTAMP(), NULL);"; mysql_query($sql, $connection); &lt;? $result= mysql_query("SELECT * FROM ptb_sessions"); while($row = mysql_fetch_array($result)){ echo"&lt;div class=\"session_id\"&gt;{$row['session_id']}&lt;/div&gt;"; echo"&lt;div class=\"user_ip\"&gt;{$row['user_ip']}&lt;/div&gt;"; $dt_obj = new DateTime($row2['session_start']." UTC"); $dt_obj-&gt;setTimezone(new DateTimeZone('Europe/London')); echo"&lt;div class=\"session_start\"&gt;$formatted_date_long=date_format($dt_obj, 'Y-m-d H:i:s')&lt;/div&gt;"; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload