Timezone: Difference between revisions
No edit summary |
Wikiservice (talk | contribs) (Refresh MemCP documentation: accuracy, operational guidance, performance profile and maintained API reference) |
||
| Line 1: | Line 1: | ||
<!-- Copyright (C) 2026 Carl-Philip Haensch --> | |||
<!-- SPDX-License-Identifier: GPL-3.0-or-later --> | |||
<span id="timezone"></span> | |||
= Timezone = | |||
<!-- Generated from MemCP c42e19eba on 2026-08-27; do not edit manually. --> | |||
<div class="mw-message-box mw-message-box-notice">Generated from MemCP commit <code>c42e19eba</code> on 27 August 2026. See [[Full SCM API documentation]].</div> | |||
The '''Timezone''' module supplies MySQL- and PostgreSQL-compatible timezone operations. It converts timestamps between named zones, exposes UTC and system/session time values, and calculates timestamp differences in SQL units. | |||
Timezone names and daylight-saving transitions depend on the deployed timezone database. Test ambiguous or nonexistent local times and avoid treating a wall-clock timestamp without zone context as a globally unique instant. | |||
== unix_timestamp == | == unix_timestamp == | ||
| Line 16: | Line 26: | ||
=== Returns === | === Returns === | ||
<code>int</code> | * '''value''' (<code>int</code>) | ||
== system_time_zone == | == system_time_zone == | ||
| Line 32: | Line 42: | ||
=== Returns === | === Returns === | ||
<code>string</code> | * '''value''' (<code>string</code>) | ||
== convert_tz == | == convert_tz == | ||
| Line 50: | Line 60: | ||
=== Returns === | === Returns === | ||
<code>date</code> | * '''value''' (<code>date</code>) | ||
== from_unixtime == | == from_unixtime == | ||
| Line 67: | Line 77: | ||
=== Returns === | === Returns === | ||
<code>date</code> | * '''value''' (<code>date</code>) | ||
== utc_timestamp == | == utc_timestamp == | ||
| Line 83: | Line 93: | ||
=== Returns === | === Returns === | ||
<code>date</code> | * '''value''' (<code>date</code>) | ||
== utc_date == | == utc_date == | ||
| Line 99: | Line 109: | ||
=== Returns === | === Returns === | ||
<code>date</code> | * '''value''' (<code>date</code>) | ||
== utc_time == | == utc_time == | ||
| Line 115: | Line 125: | ||
=== Returns === | === Returns === | ||
<code>date</code> | * '''value''' (<code>date</code>) | ||
== sysdate == | == sysdate == | ||
| Line 131: | Line 141: | ||
=== Returns === | === Returns === | ||
<code>date</code> | * '''value''' (<code>date</code>) | ||
== at_time_zone == | == at_time_zone == | ||
| Line 148: | Line 158: | ||
=== Returns === | === Returns === | ||
<code>date</code> | * '''value''' (<code>date</code>) | ||
== timestampdiff == | == timestampdiff == | ||
| Line 166: | Line 176: | ||
=== Returns === | === Returns === | ||
<code>int</code> | * '''value''' (<code>int</code>) | ||
Latest revision as of 11:59, 28 August 2026
Timezone
The Timezone module supplies MySQL- and PostgreSQL-compatible timezone operations. It converts timestamps between named zones, exposes UTC and system/session time values, and calculates timestamp differences in SQL units.
Timezone names and daylight-saving transitions depend on the deployed timezone database. Test ambiguous or nonexistent local times and avoid treating a wall-clock timestamp without zone context as a globally unique instant.
unix_timestamp
returns a unix timestamp (integer seconds since epoch)
Allowed number of parameters: 0–1
Parameters
- dt (
any): optional datetime value to convert (optional)
Returns
- value (
int)
system_time_zone
returns the operating system's local timezone name
Allowed number of parameters: 0–0
Parameters
This function has no parameters.
Returns
- value (
string)
convert_tz
converts a datetime from one timezone to another
Allowed number of parameters: 3–3
Parameters
- dt (
any): datetime value - from_tz (
string): source timezone - to_tz (
string): target timezone
Returns
- value (
date)
from_unixtime
converts a unix timestamp to a datetime in the session timezone
Allowed number of parameters: 1–2
Parameters
- unix_ts (
number): unix timestamp (seconds since epoch) - format (
string): optional MySQL format string (optional)
Returns
- value (
date)
utc_timestamp
returns the current UTC datetime
Allowed number of parameters: 0–0
Parameters
This function has no parameters.
Returns
- value (
date)
utc_date
returns the current UTC date (midnight)
Allowed number of parameters: 0–0
Parameters
This function has no parameters.
Returns
- value (
date)
utc_time
returns the current UTC time (as a datetime at epoch date)
Allowed number of parameters: 0–0
Parameters
This function has no parameters.
Returns
- value (
date)
sysdate
returns the current datetime (re-evaluated per call, unlike now())
Allowed number of parameters: 0–0
Parameters
This function has no parameters.
Returns
- value (
date)
at_time_zone
PostgreSQL AT TIME ZONE operator: converts between timezones
Allowed number of parameters: 2–2
Parameters
- dt (
any): datetime value - zone (
string): target timezone
Returns
- value (
date)
timestampdiff
returns the difference between two datetimes in the given unit
Allowed number of parameters: 3–3
Parameters
- unit (
string): SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR - dt1 (
any): first datetime - dt2 (
any): second datetime
Returns
- value (
int)