MariaDB UTC_TIMESTAMP(): UTC Time, Precision, and NOW() Difference
MariaDB UTC_TIMESTAMP() returns the current date and time in Coordinated Universal Time (UTC), independent of the session’s local time zone.
Use it when an expression must explicitly produce UTC rather than the session-local value returned by functions such as NOW() or CURRENT_TIMESTAMP.
Syntax
UTC_TIMESTAMP
UTC_TIMESTAMP()
UTC_TIMESTAMP(precision)
precision controls fractional seconds and can be from 0 through 6.
Basic example
SELECT UTC_TIMESTAMP();
Example result:
2026-10-07 15:42:18The exact value depends on when the statement runs.
Fractional-second precision
SELECT
UTC_TIMESTAMP(0) AS seconds_only,
UTC_TIMESTAMP(3) AS milliseconds,
UTC_TIMESTAMP(6) AS microseconds;
A precision of 6 keeps up to six fractional digits.
UTC_TIMESTAMP() vs NOW()
UTC_TIMESTAMP() always represents UTC. NOW() uses the current session time zone.
You can see the difference explicitly:
SET time_zone = '+08:00';
SELECT
NOW() AS session_time,
UTC_TIMESTAMP() AS utc_time;
If the session is UTC+08:00, session_time is eight hours ahead of utc_time for the same instant.
This distinction matters when:
- comparing application timestamps across regions;
- generating UTC audit values;
- debugging session time-zone configuration;
- exchanging timestamps with systems that standardize on UTC.
String and numeric context
MariaDB can return different textual forms depending on expression context:
SELECT
UTC_TIMESTAMP() AS datetime_value,
UTC_TIMESTAMP() + 0 AS numeric_value;
The numeric form uses a compact YYYYMMDDHHMMSS.uuuuuu representation.
Store UTC intentionally
If an application standardizes on UTC, be explicit about the convention. A timestamp column, server/session time-zone settings, application serialization, and display conversion are separate concerns; UTC_TIMESTAMP() only supplies the current UTC value.