<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="time-zone-support">
      </a>
      7.1.15 MySQL Server Time Zone Support
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045260470800">
  </a>
  <p>
   This section describes the time zone settings maintained by MySQL,
      how to load the system tables required for named time support, how
      to stay current with time zone changes, and how to enable
      leap-second support.
  </p>
  <p>
   Time zone offsets are also supported for inserted datetime values;
      see
   <a class="xref" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
    Section 13.2.2, “The DATE, DATETIME, and TIMESTAMP Types”
   </a>
   , for more information.
  </p>
  <p>
   For information about time zone settings in replication setups,
      see
   <a class="xref" href="replication-features-functions.html" title="19.5.1.14 Replication and System Functions">
    Section 19.5.1.14, “Replication and System Functions”
   </a>
   and
   <a class="xref" href="replication-features-timezone.html" title="19.5.1.33 Replication and Time Zones">
    Section 19.5.1.33, “Replication and Time Zones”
   </a>
   .
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="time-zone-support.html#time-zone-variables" title="Time Zone Variables">
       Time Zone Variables
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="time-zone-support.html#time-zone-installation" title="Populating the Time Zone Tables">
       Populating the Time Zone Tables
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="time-zone-support.html#time-zone-upgrades" title="Staying Current with Time Zone Changes">
       Staying Current with Time Zone Changes
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="time-zone-support.html#time-zone-leap-seconds" title="Time Zone Leap Second Support">
       Time Zone Leap Second Support
      </a>
     </p>
    </li>
   </ul>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="time-zone-variables">
       </a>
       Time Zone Variables
      </h4>
     </div>
    </div>
   </div>
   <p>
    MySQL Server maintains several time zone settings:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       The server system time zone. When the server starts, it
            attempts to determine the time zone of the host machine and
            uses it to set the
       <a class="link" href="server-system-variables.html#sysvar_system_time_zone">
        <code class="literal">
         system_time_zone
        </code>
       </a>
       system
            variable.
      </p>
      <a class="indexterm" name="idm46045260456960">
      </a>
      <a class="indexterm" name="idm46045260455872">
      </a>
      <a class="indexterm" name="idm46045260454384">
      </a>
      <a class="indexterm" name="idm46045260453312">
      </a>
      <p>
       To explicitly specify the system time zone for MySQL Server
            at startup, set the
       <code class="literal">
        TZ
       </code>
       environment
            variable before you start
       <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
        <span class="command">
         <strong>
          mysqld
         </strong>
        </span>
       </a>
       . If you
            start the server using
       <a class="link" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
        <span class="command">
         <strong>
          mysqld_safe
         </strong>
        </span>
       </a>
       , its
       <a class="link" href="mysqld-safe.html#option_mysqld_safe_timezone">
        <code class="option">
         --timezone
        </code>
       </a>
       option
            provides another way to set the system time zone. The
            permissible values for
       <code class="literal">
        TZ
       </code>
       and
       <a class="link" href="mysqld-safe.html#option_mysqld_safe_timezone">
        <code class="option">
         --timezone
        </code>
       </a>
       are system
            dependent. Consult your operating system documentation to
            see what values are acceptable.
      </p>
     </li>
     <li class="listitem">
      <p>
       The server current time zone. The global
       <a class="link" href="server-system-variables.html#sysvar_time_zone">
        <code class="literal">
         time_zone
        </code>
       </a>
       system variable
            indicates the time zone the server currently is operating
            in. The initial
       <a class="link" href="server-system-variables.html#sysvar_time_zone">
        <code class="literal">
         time_zone
        </code>
       </a>
       value is
       <code class="literal">
        'SYSTEM'
       </code>
       , which indicates that
            the server time zone is the same as the system time zone.
      </p>
      <a class="indexterm" name="idm46045260441024">
      </a>
      <a class="indexterm" name="idm46045260439936">
      </a>
      <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
       <div class="admon-title">
        Note
       </div>
       <p>
        If set to
        <code class="literal">
         SYSTEM
        </code>
        , every MySQL function
              call that requires a time zone calculation makes a system
              library call to determine the current system time zone.
              This call may be protected by a global mutex, resulting in
              contention.
       </p>
      </div>
      <p>
       The initial global server time zone value can be specified
            explicitly at startup with the
       <a class="link" href="server-options.html#option_mysqld_default-time-zone">
        <code class="option">
         --default-time-zone
        </code>
       </a>
       option on
            the command line, or you can use the following line in an
            option file:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-ini"><div class="docs-select-all right" id="sa34247275"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token constant">default-time-zone</span><span class="token attr-value"><span class="token punctuation">=</span>'<em class="replaceable">timezone</em>'</span></code></pre>
      </div>
      <p>
       If you have the
       <a class="link" href="privileges-provided.html#priv_system-variables-admin">
        <code class="literal">
         SYSTEM_VARIABLES_ADMIN
        </code>
       </a>
       privilege (or the deprecated
       <a class="link" href="privileges-provided.html#priv_super">
        <code class="literal">
         SUPER
        </code>
       </a>
       privilege), you can set
            the global server time zone value at runtime with this
            statement:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa97711435"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> time_zone <span class="token operator">=</span> <em class="replaceable">timezone</em><span class="token punctuation">;</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       Per-session time zones. Each client that connects has its
            own session time zone setting, given by the session
       <a class="link" href="server-system-variables.html#sysvar_time_zone">
        <code class="literal">
         time_zone
        </code>
       </a>
       variable.
            Initially, the session variable takes its value from the
            global
       <a class="link" href="server-system-variables.html#sysvar_time_zone">
        <code class="literal">
         time_zone
        </code>
       </a>
       variable,
            but the client can change its own time zone with this
            statement:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa78304308"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> time_zone <span class="token operator">=</span> <em class="replaceable">timezone</em><span class="token punctuation">;</span></code></pre>
      </div>
     </li>
    </ul>
   </div>
   <p>
    The session time zone setting affects display and storage of
        time values that are zone-sensitive. This includes the values
        displayed by functions such as
    <a class="link" href="date-and-time-functions.html#function_now">
     <code class="literal">
      NOW()
     </code>
    </a>
    or
    <a class="link" href="date-and-time-functions.html#function_curtime">
     <code class="literal">
      CURTIME()
     </code>
    </a>
    , and values stored in
        and retrieved from
    <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
     <code class="literal">
      TIMESTAMP
     </code>
    </a>
    columns. Values for
    <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
     <code class="literal">
      TIMESTAMP
     </code>
    </a>
    columns are converted from the session time zone to UTC for
        storage, and from UTC to the session time zone for retrieval.
   </p>
   <p>
    The session time zone setting does not affect values displayed
        by functions such as
    <a class="link" href="date-and-time-functions.html#function_utc-timestamp">
     <code class="literal">
      UTC_TIMESTAMP()
     </code>
    </a>
    or values in
    <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
     <code class="literal">
      DATE
     </code>
    </a>
    ,
    <a class="link" href="time.html" title="13.2.3 The TIME Type">
     <code class="literal">
      TIME
     </code>
    </a>
    , or
    <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
     <code class="literal">
      DATETIME
     </code>
    </a>
    columns. Nor are values
        in those data types stored in UTC; the time zone applies for
        them only when converting from
    <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
     <code class="literal">
      TIMESTAMP
     </code>
    </a>
    values. If you want
        locale-specific arithmetic for
    <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
     <code class="literal">
      DATE
     </code>
    </a>
    ,
    <a class="link" href="time.html" title="13.2.3 The TIME Type">
     <code class="literal">
      TIME
     </code>
    </a>
    , or
    <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
     <code class="literal">
      DATETIME
     </code>
    </a>
    values, convert them to
        UTC, perform the arithmetic, and then convert back.
   </p>
   <p>
    The current global and session time zone values can be retrieved
        like this:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa33667617"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token variable">@@GLOBAL.time_zone</span><span class="token punctuation">,</span> <span class="token variable">@@SESSION.time_zone</span><span class="token punctuation">;</span></code></pre>
   </div>
   <p>
    <em class="replaceable">
     <code>
      timezone
     </code>
    </em>
    values can be given in
        several formats, none of which are case-sensitive:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       As the value
       <code class="literal">
        'SYSTEM'
       </code>
       , indicating that
            the server time zone is the same as the system time zone.
      </p>
     </li>
     <li class="listitem">
      <p>
       As a string indicating an offset from UTC of the form
       <code class="literal">
        [
        <em class="replaceable">
         <code>
          H
         </code>
        </em>
        ]
        <em class="replaceable">
         <code>
          H
         </code>
        </em>
        :
        <em class="replaceable">
         <code>
          MM
         </code>
        </em>
       </code>
       ,
            prefixed with a
       <code class="literal">
        +
       </code>
       or
       <code class="literal">
        -
       </code>
       , such as
       <code class="literal">
        '+10:00'
       </code>
       ,
       <code class="literal">
        '-6:00'
       </code>
       , or
       <code class="literal">
        '+05:30'
       </code>
       .
            A leading zero can optionally be used for hours values less
            than 10; MySQL prepends a leading zero when storing and
            retrieving the value in such cases. MySQL converts
       <code class="literal">
        '-00:00'
       </code>
       or
       <code class="literal">
        '-0:00'
       </code>
       to
       <code class="literal">
        '+00:00'
       </code>
       .
      </p>
      <p>
       This value must be in the range
       <code class="literal">
        '-13:59'
       </code>
       to
       <code class="literal">
        '+14:00'
       </code>
       , inclusive.
      </p>
     </li>
     <li class="listitem">
      <p>
       As a named time zone, such as
       <code class="literal">
        'Europe/Helsinki'
       </code>
       ,
       <code class="literal">
        'US/Eastern'
       </code>
       ,
       <code class="literal">
        'MET'
       </code>
       ,
            or
       <code class="literal">
        'UTC'
       </code>
       .
      </p>
      <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
       <div class="admon-title">
        Note
       </div>
       <p>
        Named time zones can be used only if the time zone
              information tables in the
        <code class="literal">
         mysql
        </code>
        database have been created and populated. Otherwise, use
              of a named time zone results in an error:
       </p>
       <a class="indexterm" name="idm46045260387536">
       </a>
       <a class="indexterm" name="idm46045260386032">
       </a>
       <div class="copytoclipboard-wrapper">
        <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa3914316"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> time_zone <span class="token operator">=</span> <span class="token string">'UTC'</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1298 (HY000)<span class="token punctuation">:</span> Unknown or incorrect time zone<span class="token punctuation">:</span> 'UTC'</span></code></pre>
       </div>
      </div>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="time-zone-installation">
       </a>
       Populating the Time Zone Tables
      </h4>
     </div>
    </div>
   </div>
   <p>
    Several tables in the
    <code class="literal">
     mysql
    </code>
    system schema
        exist to store time zone information (see
    <a class="xref" href="system-schema.html" title="7.3 The mysql System Schema">
     Section 7.3, “The mysql System Schema”
    </a>
    ). The MySQL installation
        procedure creates the time zone tables, but does not load them.
        To do so manually, use the following instructions.
   </p>
   <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
    <div class="admon-title">
     Note
    </div>
    <p>
     Loading the time zone information is not necessarily a
          one-time operation because the information changes
          occasionally. When such changes occur, applications that use
          the old rules become out of date and you may find it necessary
          to reload the time zone tables to keep the information used by
          your MySQL server current. See
     <a class="xref" href="time-zone-support.html#time-zone-upgrades" title="Staying Current with Time Zone Changes">
      Staying Current with Time Zone Changes
     </a>
     .
    </p>
   </div>
   <p>
    If your system has its own
    <span class="firstterm">
     zoneinfo
    </span>
    database (the set
        of files describing time zones), use the
    <a class="link" href="mysql-tzinfo-to-sql.html" title="6.4.3 mysql_tzinfo_to_sql — Load the Time Zone Tables">
     <span class="command">
      <strong>
       mysql_tzinfo_to_sql
      </strong>
     </span>
    </a>
    program to load the time
        zone tables. Examples of such systems are Linux, macOS, FreeBSD,
        and Solaris. One likely location for these files is the
    <code class="filename">
     /usr/share/zoneinfo
    </code>
    directory. If your
        system has no zoneinfo database, you can use a downloadable
        package, as described later in this section.
   </p>
   <p>
    To load the time zone tables from the command line, pass the
        zoneinfo directory path name to
    <a class="link" href="mysql-tzinfo-to-sql.html" title="6.4.3 mysql_tzinfo_to_sql — Load the Time Zone Tables">
     <span class="command">
      <strong>
       mysql_tzinfo_to_sql
      </strong>
     </span>
    </a>
    and send the output into
        the
    <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
     <span class="command">
      <strong>
       mysql
      </strong>
     </span>
    </a>
    program. For example:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa53835569"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql <span class="token property">-u</span> root <span class="token property">-p</span> mysql</code></pre>
   </div>
   <p>
    The
    <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
     <span class="command">
      <strong>
       mysql
      </strong>
     </span>
    </a>
    command shown here assumes that you
        connect to the server using an account such as
    <code class="literal">
     root
    </code>
    that has privileges for modifying tables
        in the
    <code class="literal">
     mysql
    </code>
    system schema. Adjust the
        connection parameters as required.
   </p>
   <p>
    <a class="link" href="mysql-tzinfo-to-sql.html" title="6.4.3 mysql_tzinfo_to_sql — Load the Time Zone Tables">
     <span class="command">
      <strong>
       mysql_tzinfo_to_sql
      </strong>
     </span>
    </a>
    reads your system's time
        zone files and generates SQL statements from them.
    <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
     <span class="command">
      <strong>
       mysql
      </strong>
     </span>
    </a>
    processes those statements to load the
        time zone tables.
   </p>
   <p>
    <a class="link" href="mysql-tzinfo-to-sql.html" title="6.4.3 mysql_tzinfo_to_sql — Load the Time Zone Tables">
     <span class="command">
      <strong>
       mysql_tzinfo_to_sql
      </strong>
     </span>
    </a>
    also can be used to load
        a single time zone file or generate leap second information:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       To load a single time zone file
       <em class="replaceable">
        <code>
         tz_file
        </code>
       </em>
       that corresponds to a
            time zone name
       <em class="replaceable">
        <code>
         tz_name
        </code>
       </em>
       , invoke
       <a class="link" href="mysql-tzinfo-to-sql.html" title="6.4.3 mysql_tzinfo_to_sql — Load the Time Zone Tables">
        <span class="command">
         <strong>
          mysql_tzinfo_to_sql
         </strong>
        </span>
       </a>
       like this:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa71338347"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql_tzinfo_to_sql <em class="replaceable">tz_file</em> <em class="replaceable">tz_name</em> | mysql <span class="token property">-u</span> root <span class="token property">-p</span> mysql</code></pre>
      </div>
      <p>
       With this approach, you must execute a separate command to
            load the time zone file for each named zone that the server
            needs to know about.
      </p>
     </li>
     <li class="listitem">
      <p>
       If your time zone must account for leap seconds, initialize
            leap second information like this, where
       <em class="replaceable">
        <code>
         tz_file
        </code>
       </em>
       is the name of your time
            zone file:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa89093648"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql_tzinfo_to_sql <span class="token property">--leap</span> <em class="replaceable">tz_file</em> | mysql <span class="token property">-u</span> root <span class="token property">-p</span> mysql</code></pre>
      </div>
     </li>
    </ul>
   </div>
   <p>
    After running
    <a class="link" href="mysql-tzinfo-to-sql.html" title="6.4.3 mysql_tzinfo_to_sql — Load the Time Zone Tables">
     <span class="command">
      <strong>
       mysql_tzinfo_to_sql
      </strong>
     </span>
    </a>
    , restart
        the server so that it does not continue to use any previously
        cached time zone data.
   </p>
   <p>
    If your system has no zoneinfo database (for example, Windows),
        you can use a package containing SQL statements that is
        available for download at the MySQL Developer Zone:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa7767967"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">https<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>dev<span class="token punctuation">.</span>mysql<span class="token punctuation">.</span>com<span class="token operator">/</span>downloads<span class="token operator">/</span>timezones<span class="token punctuation">.</span>html</code></pre>
   </div>
   <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
    <div class="admon-title">
     Warning
    </div>
    <p>
     Do
     <span class="emphasis">
      <em>
       not
      </em>
     </span>
     use a downloadable time zone
          package if your system has a zoneinfo database. Use the
     <a class="link" href="mysql-tzinfo-to-sql.html" title="6.4.3 mysql_tzinfo_to_sql — Load the Time Zone Tables">
      <span class="command">
       <strong>
        mysql_tzinfo_to_sql
       </strong>
      </span>
     </a>
     utility instead.
          Otherwise, you may cause a difference in datetime handling
          between MySQL and other applications on your system.
    </p>
   </div>
   <p>
    To use an SQL-statement time zone package that you have
        downloaded, unpack it, then load the unpacked file contents into
        the time zone tables:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa4033101"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql <span class="token property">-u</span> root <span class="token property">-p</span> mysql &lt; <em class="replaceable">file_name</em></code></pre>
   </div>
   <p>
    Then restart the server.
   </p>
   <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
    <div class="admon-title">
     Warning
    </div>
    <p>
     Do
     <span class="emphasis">
      <em>
       not
      </em>
     </span>
     use a downloadable time zone
          package that contains
     <code class="literal">
      MyISAM
     </code>
     tables. That
          is intended for older MySQL versions. MySQL now uses
     <code class="literal">
      InnoDB
     </code>
     for the time zone tables. Trying to
          replace them with
     <code class="literal">
      MyISAM
     </code>
     tables causes
          problems.
    </p>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="time-zone-upgrades">
       </a>
       Staying Current with Time Zone Changes
      </h4>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045260338784">
   </a>
   <p>
    When time zone rules change, applications that use the old rules
        become out of date. To stay current, it is necessary to make
        sure that your system uses current time zone information is
        used. For MySQL, there are multiple factors to consider in
        staying current:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       The operating system time affects the value that the MySQL
            server uses for times if its time zone is set to
       <code class="literal">
        SYSTEM
       </code>
       . Make sure that your operating
            system is using the latest time zone information. For most
            operating systems, the latest update or service pack
            prepares your system for the time changes. Check the website
            for your operating system vendor for an update that
            addresses the time changes.
      </p>
     </li>
     <li class="listitem">
      <p>
       If you replace the system's
       <code class="filename">
        /etc/localtime
       </code>
       time zone file with a
            version that uses rules differing from those in effect at
       <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
        <span class="command">
         <strong>
          mysqld
         </strong>
        </span>
       </a>
       startup, restart
       <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
        <span class="command">
         <strong>
          mysqld
         </strong>
        </span>
       </a>
       so that it uses the updated rules.
            Otherwise,
       <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
        <span class="command">
         <strong>
          mysqld
         </strong>
        </span>
       </a>
       might not notice when
            the system changes its time.
      </p>
     </li>
     <li class="listitem">
      <p>
       If you use named time zones with MySQL, make sure that the
            time zone tables in the
       <code class="literal">
        mysql
       </code>
       database
            are up to date:
      </p>
      <div class="itemizedlist">
       <ul class="itemizedlist" style="list-style-type: circle; ">
        <li class="listitem">
         <p>
          If your system has its own zoneinfo database, reload the
                MySQL time zone tables whenever the zoneinfo database is
                updated.
         </p>
        </li>
        <li class="listitem">
         <p>
          For systems that do not have their own zoneinfo
                database, check the MySQL Developer Zone for updates.
                When a new update is available, download it and use it
                to replace the content of your current time zone tables.
         </p>
        </li>
       </ul>
      </div>
      <p>
       For instructions for both methods, see
       <a class="xref" href="time-zone-support.html#time-zone-installation" title="Populating the Time Zone Tables">
        Populating the Time Zone Tables
       </a>
       .
       <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
        <span class="command">
         <strong>
          mysqld
         </strong>
        </span>
       </a>
       caches time zone information that
            it looks up, so after updating the time zone tables, restart
       <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
        <span class="command">
         <strong>
          mysqld
         </strong>
        </span>
       </a>
       to make sure that it does not
            continue to serve outdated time zone data.
      </p>
     </li>
    </ul>
   </div>
   <p>
    If you are uncertain whether named time zones are available, for
        use either as the server's time zone setting or by clients that
        set their own time zone, check whether your time zone tables are
        empty. The following query determines whether the table that
        contains time zone names has any rows:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa12823191"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> mysql<span class="token punctuation">.</span>time_zone_name<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> COUNT(*) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>        0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
   </div>
   <p>
    A count of zero indicates that the table is empty. In this case,
        no applications currently are using named time zones, and you
        need not update the tables (unless you want to enable named time
        zone support). A count greater than zero indicates that the
        table is not empty and that its contents are available to be
        used for named time zone support. In this case, be sure to
        reload your time zone tables so that applications that use named
        time zones can obtain correct query results.
   </p>
   <a class="indexterm" name="idm46045260317488">
   </a>
   <p>
    To check whether your MySQL installation is updated properly for
        a change in Daylight Saving Time rules, use a test like the one
        following. The example uses values that are appropriate for the
        2007 DST 1-hour change that occurs in the United States on March
        11 at 2 a.m.
   </p>
   <p>
    The test uses this query:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa89635680"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span>
  <span class="token function">CONVERT_TZ</span><span class="token punctuation">(</span><span class="token string">'2007-03-11 2:00:00'</span><span class="token punctuation">,</span><span class="token string">'US/Eastern'</span><span class="token punctuation">,</span><span class="token string">'US/Central'</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> time1<span class="token punctuation">,</span>
  <span class="token function">CONVERT_TZ</span><span class="token punctuation">(</span><span class="token string">'2007-03-11 3:00:00'</span><span class="token punctuation">,</span><span class="token string">'US/Eastern'</span><span class="token punctuation">,</span><span class="token string">'US/Central'</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> time2<span class="token punctuation">;</span></code></pre>
   </div>
   <p>
    The two time values indicate the times at which the DST change
        occurs, and the use of named time zones requires that the time
        zone tables be used. The desired result is that both queries
        return the same result (the input time, converted to the
        equivalent value in the 'US/Central' time zone).
   </p>
   <p>
    Before updating the time zone tables, you see an incorrect
        result like this:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa96394446"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> time1               <span class="token punctuation">|</span> time2               <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2007<span class="token punctuation">-</span>03<span class="token punctuation">-</span>11 01:00:00 <span class="token punctuation">|</span> 2007<span class="token punctuation">-</span>03<span class="token punctuation">-</span>11 02:00:00 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
   </div>
   <p>
    After updating the tables, you should see the correct result:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa73600921"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> time1               <span class="token punctuation">|</span> time2               <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2007<span class="token punctuation">-</span>03<span class="token punctuation">-</span>11 01:00:00 <span class="token punctuation">|</span> 2007<span class="token punctuation">-</span>03<span class="token punctuation">-</span>11 01:00:00 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="time-zone-leap-seconds">
       </a>
       Time Zone Leap Second Support
      </h4>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045260308928">
   </a>
   <p>
    Leap second values are returned with a time part that ends with
    <code class="literal">
     :59:59
    </code>
    . This means that a function such as
    <a class="link" href="date-and-time-functions.html#function_now">
     <code class="literal">
      NOW()
     </code>
    </a>
    can return the same value
        for two or three consecutive seconds during the leap second. It
        remains true that literal temporal values having a time part
        that ends with
    <code class="literal">
     :59:60
    </code>
    or
    <code class="literal">
     :59:61
    </code>
    are considered invalid.
   </p>
   <p>
    If it is necessary to search for
    <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
     <code class="literal">
      TIMESTAMP
     </code>
    </a>
    values one second
        before the leap second, anomalous results may be obtained if you
        use a comparison with
    <code class="literal">
     '
     <em class="replaceable">
      <code>
       YYYY-MM-DD
        hh:mm:ss
      </code>
     </em>
     '
    </code>
    values. The following example
        demonstrates this. It changes the session time zone to UTC so
        there is no difference between internal
    <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
     <code class="literal">
      TIMESTAMP
     </code>
    </a>
    values (which are in
        UTC) and displayed values (which have time zone correction
        applied).
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa75477047"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t1 <span class="token punctuation">(</span>
         a <span class="token datatype">INT</span><span class="token punctuation">,</span>
         ts <span class="token datatype">TIMESTAMP</span> <span class="token keyword">DEFAULT</span> <span class="token keyword">CURRENT_TIMESTAMP</span><span class="token punctuation">,</span>
         <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span> <span class="token punctuation">(</span>ts<span class="token punctuation">)</span>
       <span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.01 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token comment" spellcheck="true">-- change to UTC</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> time_zone <span class="token operator">=</span> <span class="token string">'+00:00'</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token comment" spellcheck="true">-- Simulate NOW() = '2008-12-31 23:59:59'</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token datatype">timestamp</span> <span class="token operator">=</span> <span class="token number">1230767999</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t1 <span class="token punctuation">(</span>a<span class="token punctuation">)</span> <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 1 row affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token comment" spellcheck="true">-- Simulate NOW() = '2008-12-31 23:59:60'</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token datatype">timestamp</span> <span class="token operator">=</span> <span class="token number">1230768000</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t1 <span class="token punctuation">(</span>a<span class="token punctuation">)</span> <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 1 row affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token comment" spellcheck="true">-- values differ internally but display the same</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> a<span class="token punctuation">,</span> ts<span class="token punctuation">,</span> <span class="token function">UNIX_TIMESTAMP</span><span class="token punctuation">(</span>ts<span class="token punctuation">)</span> <span class="token keyword">FROM</span> t1<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a    <span class="token punctuation">|</span> ts                  <span class="token punctuation">|</span> UNIX_TIMESTAMP(ts) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>    1 <span class="token punctuation">|</span> 2008<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 23:59:59 <span class="token punctuation">|</span>         1230767999 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>    2 <span class="token punctuation">|</span> 2008<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 23:59:59 <span class="token punctuation">|</span>         1230768000 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">2 rows in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token comment" spellcheck="true">-- only the non-leap value matches</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> ts <span class="token operator">=</span> <span class="token string">'2008-12-31 23:59:59'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a    <span class="token punctuation">|</span> ts                  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>    1 <span class="token punctuation">|</span> 2008<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 23:59:59 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token comment" spellcheck="true">-- the leap value with seconds=60 is invalid</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> ts <span class="token operator">=</span> <span class="token string">'2008-12-31 23:59:60'</span><span class="token punctuation">;</span>
<span class="token keyword">Empty</span> <span class="token keyword">set</span><span class="token punctuation">,</span> <span class="token number">2</span> <span class="token keyword">warnings</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
   </div>
   <p>
    To work around this, you can use a comparison based on the UTC
        value actually stored in the column, which has the leap second
        correction applied:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa5070168"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token comment" spellcheck="true">-- selecting using UNIX_TIMESTAMP value return leap value</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> <span class="token function">UNIX_TIMESTAMP</span><span class="token punctuation">(</span>ts<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token number">1230768000</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a    <span class="token punctuation">|</span> ts                  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>    2 <span class="token punctuation">|</span> 2008<span class="token punctuation">-</span>12<span class="token punctuation">-</span>31 23:59:59 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
   </div>
  </div>
 </div>
 <br/>
</div>
