MySQL UTC_TIME() Function
In MySQL, the UTC_TIME()
function returns the current UTC time.
If the UTC_TIME()
function is used in a string context, the returned value is in 'hh:mm:ss'
format, and if it is used in a numeric context, the returned value is in hhmmss
format.
UTC_TIME()
Syntax
Here is the syntax of MySQL UTC_TIME()
function:
UTC_TIME()
or
UTC_TIME(fsp)
Parameters
fsp
- Optional. The fractional seconds precision from
0
to6
. The default is0
.
UTC_TIME()
Examples
Get UTC time
Returns the current UTC time.
SELECT UTC_TIME(), UTC_TIME() + 0;
+------------+----------------+
| UTC_TIME() | UTC_TIME() + 0 |
+------------+----------------+
| 11:37:15 | 113715 |
+------------+----------------+
Note: The result of UTC_TIME() + 0
is in hhmmss
format.
UTC_TIME() + N
means adding N
seconds to the current time. For example:
SELECT UTC_TIME(), UTC_TIME() + 1;
+------------+----------------+
| UTC_TIME() | UTC_TIME() + 1 |
+------------+----------------+
| 11:37:27 | 113728 |
+------------+----------------+
Fractional seconds
You can specify a fractional seconds precision from 0 to 6.
SELECT UTC_TIME(1), UTC_TIME(6);
+-------------+-----------------+
| UTC_TIME(1) | UTC_TIME(6) |
+-------------+-----------------+
| 14:42:31.8 | 14:42:31.839497 |
+-------------+-----------------+