SQL Keywords

SQL UTC_TIME

What is SQL UTC_TIME?

Returns the current Coordinated Universal Time (UTC) as a TIME value (HH:MM:SS) with optional fractional seconds.
Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Compatible dialects for SQL UTC_TIME:

SQL UTC_TIME Full Explanation

UTC_TIME is a MySQL and MariaDB built-in date-and-time function that outputs the current time at the zero-offset UTC time zone. Unlike NOW() or CURRENT_TIME, the result is never dependent on the session or system time_zone setting. The function can be called without arguments or with an optional fractional-seconds precision (fsp) argument that ranges from 0 to 6. Internally, MySQL converts the host machine’s clock to UTC, then trims the date portion, returning only the time. The data type of the result is TIME; in string context it appears as 'HH:MM:SS[.fraction]'. Because no date component is included, the value cannot on its own determine whether it belongs to today or the previous/next day in other time zones. UTC_TIME is deterministic within a single statement but non-deterministic across statements because its value changes as time advances.

SQL UTC_TIME Syntax

UTC_TIME[(fsp)];

SQL UTC_TIME Parameters

Example Queries Using SQL UTC_TIME

-- Basic usage
SELECT UTC_TIME();

-- With millisecond precision
SELECT UTC_TIME(3);

-- Compare local and UTC time
SELECT CURRENT_TIME()   AS local_time,
       UTC_TIME()       AS utc_time,
       TIMEDIFF(CURRENT_TIME(), UTC_TIME()) AS tz_offset;

Expected Output Using SQL UTC_TIME

  • Each SELECT returns the current UTC time
  • The first call returns something like '14:23:05'
  • The second includes milliseconds such as '14:23:05
  • 123'
  • The comparison query also shows the time zone offset between the server session and UTC

Use Cases with SQL UTC_TIME

  • Store time stamps in a time-zone-agnostic format for distributed systems
  • Generate logs that must be correlated across servers in multiple regions
  • Audit triggers that require consistent reference time regardless of session settings
  • Calculate offsets between local server time and UTC for diagnostics

Common Mistakes with SQL UTC_TIME

  • Assuming UTC_TIME includes a date component
  • Omitting parentheses in strict SQL modes (write UTC_TIME() even with no fsp)
  • Using UTC_TIME in databases other than MySQL or MariaDB where it is undefined
  • Supplying fsp outside the 0-6 range, which raises an error
  • Forgetting that the function value changes during a long-running transaction, so use SET @t := UTC_TIME() to freeze it

Related Topics

First Introduced In

MySQL 4.1

Frequently Asked Questions

What does UTC_TIME return?

UTC_TIME returns the current Coordinated Universal Time in HH:MM:SS format (plus optional fractional seconds). No date component is included.

How do I include milliseconds?

Pass a fractional-second precision argument: `SELECT UTC_TIME(3);` returns a value like 14:23:05.123.

Does UTC_TIME respect the session time zone?

No. UTC_TIME always reports the time at UTC+00:00, ignoring `@@session.time_zone`.

What databases support UTC_TIME?

Native support exists in MySQL, MariaDB, and compatible forks like TiDB. Other databases require alternate syntax to obtain UTC time.

Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.
Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo

Check out other commonly used SQL Keywords!