MySQL CURRENT_TIME() Function

The CURRENT_TIME() function in MySQL returns the current time in the format HH:MM:SS or as a numeric value in the HHMMSS.uuuuuu format.


Definition and Usage

  • The CURRENT_TIME() function returns the current time.

Syntax

CURRENT_TIME()

Technical Details

  • Works in: From MySQL 4.0
  • Return Value: Returns the current time in the format HH:MM:SS.

Examples

Example 1: Return current time

SELECT CURRENT_TIME();

Output:

14:30:15

This query will return the current time in the HH:MM:SS format.

Example 2: Return current time + 1 (next second)

SELECT CURRENT_TIME() + 1;

Output:

14:30:16

This query adds 1 second to the current time and returns the updated time.


Related Functions

  • CURTIME(): Equivalent to CURRENT_TIME().
  • NOW(): Returns the current date and time.
  • CURRENT_DATE(): Returns the current date.
  • CURRENT_TIMESTAMP(): Returns the current date and time (equivalent to NOW()).

Use Cases

  • Time-based Calculations: Useful when you need the exact time for operations, such as logging events or measuring durations.
  • Time Comparison: You can use CURRENT_TIME() in queries that filter data based on time, like comparing if a certain event occurred before or after the current time.

Was this article helpful?