Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can SELECT UTC_TIMESTAMP() return -10:00 UTC?
    primarykey
    data
    text
    <p>Either I'm being stupid or something's wrong here.</p> <p>I have two SQL Servers, the one is on my local machine (local time <strong>+2 GMT</strong>) and the other is somewhere else (<code>NOW()</code> seems to return <strong>+8 GMT</strong>)and I access it through phpMyAdmin. I have a table that has a <code>DATETIME</code> column. I'm trying </p> <blockquote> <p>to store the current <strong>GMT/UTC</strong> time and then display it again, still as GMT/UTC time.</p> </blockquote> <p>Originally I stored <code>DATE_SUB(NOW(), INTERVAL 8 HOUR)</code> which worked just fine. However, then I read about <code>UTC_TIMESTAMP()</code> and liked it more, as it was shorter and the <a href="http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html" rel="noreferrer"><code>MySQL manual</code></a> even said :</p> <blockquote> <p>"The current time zone setting does not affect values displayed by functions such as UTC_TIMESTAMP() or values in DATE, TIME, or DATETIME columns."</p> </blockquote> <p>So perfect right? Except no.</p> <p>Let's assume Current <strong>GMT is 2010-02-18 17:18:17</strong> (I even double checked it with someone in Britain).</p> <p>On <strong>my local (+2) server</strong>, I get the following results for the following queries: </p> <pre><code>SELECT NOW(); 2010-02-18 19:18:17 SELECT UTC_TIMESTAMP(); 2010-02-18 17:18:17 </code></pre> <p>On <strong>my online server</strong> I get: </p> <pre><code>SELECT NOW(); 2010-02-19 01:18:17 SELECT UTC_TIMESTAMP(); 2010-02-19 07:18:17 (WHY?!) </code></pre> <p>Am I missing something?!</p>
    singulars
    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.
 

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