MySQL Tutorial MySQL Advanced MySQL Database Account Management MySQL References

MySQL CURRENT_TIME() Function



The MySQL CURRENT_TIME() function returns the current time. It returns the current time in the following format:

  • Returns the current time as a 'HH:MM:SS' format, if used in a string context.
  • Returns the current time as a HHMMSS.uuuuuu format, if used in a numeric context.

The CURRENT_TIME() function is a synonym for the CURTIME() function.

Syntax

CURRENT_TIME()

Parameters

No parameter is required.

Return Value

Returns the current time.

Example 1:

The example below shows the usage of CURRENT_TIME() function.

mysql> SELECT CURRENT_TIME();
Result: '10:51:38'

mysql> SELECT CURRENT_TIME() + 0;
Result: 105138

mysql> SELECT CURRENT_TIME() + 1;
Result: 105139

Example 2:

Consider a database table called EmployeeLogin with the following records:

EmpIDNameDateLogin Time
1John2019-10-2509:20:38
2Marry2019-10-2509:21:05
3Jo2019-10-2509:24:35
4Kim2019-10-2509:25:24
5Ramesh2019-10-2509:27:16

To insert a new record in this table, the following statement can be used.

INSERT INTO EmployeeLogin 
VALUES (6, 'Suresh', CURRENT_DATE(), CURRENT_TIME());

-- see the result
SELECT * FROM EmployeeLogin;

This will produce a result similar to:

EmpIDNameDateLogin Time
1John2019-10-2509:20:38
2Marry2019-10-2509:21:05
3Jo2019-10-2509:24:35
4Kim2019-10-2509:25:24
5Ramesh2019-10-2509:27:16
6Suresh2019-10-2509:28:19

❮ MySQL Functions