Timezone

From MemCP
Revision as of 11:59, 28 August 2026 by Wikiservice (talk | contribs) (Refresh MemCP documentation: accuracy, operational guidance, performance profile and maintained API reference)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Timezone

Generated from MemCP commit c42e19eba on 27 August 2026. See Full SCM API documentation.

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)