MySQL CURTIME() Function
The MySQL CURTIME() 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 CURTIME() function is a synonym for the CURRENT_TIME() function.
Syntax
CURTIME()
Parameters
No parameter is required.
Return Value
Returns the current time.
Example 1:
The example below shows the usage of CURTIME() function.
mysql> SELECT CURTIME(); Result: '10:51:38' mysql> SELECT CURTIME() + 0; Result: 105138 mysql> SELECT CURTIME() + 1; Result: 105139
Example 2:
Consider a database table called EmployeeLogin with the following records:
EmpID | Name | Date | Login Time |
---|---|---|---|
1 | John | 2019-10-25 | 09:20:38 |
2 | Marry | 2019-10-25 | 09:21:05 |
3 | Jo | 2019-10-25 | 09:24:35 |
4 | Kim | 2019-10-25 | 09:25:24 |
5 | Ramesh | 2019-10-25 | 09:27:16 |
To insert a new record in this table, the following statement can be used.
INSERT INTO EmployeeLogin VALUES (6, 'Suresh', CURDATE(), CURTIME()); -- see the result SELECT * FROM EmployeeLogin;
This will produce a result similar to:
EmpID | Name | Date | Login Time |
---|---|---|---|
1 | John | 2019-10-25 | 09:20:38 |
2 | Marry | 2019-10-25 | 09:21:05 |
3 | Jo | 2019-10-25 | 09:24:35 |
4 | Kim | 2019-10-25 | 09:25:24 |
5 | Ramesh | 2019-10-25 | 09:27:16 |
6 | Suresh | 2019-10-25 | 09:28:19 |
❮ MySQL Functions