The LOCALTIME() function is used to return the current date and time in the system's local timezone.
Definition and Usage
- The
LOCALTIME()function returns the current date and time based on the system's local time zone.
Syntax
LOCALTIME()
- No parameters are required for this function.
Examples
Example 1: Return current date and time
SELECT LOCALTIME();
Output:
2024-12-28 13:15:35
This example returns the current local date and time.
Example 2: Return current date and time + 1 (adding 1 unit to the current time)
SELECT LOCALTIME() + 1;
Output:
2024-12-28 13:15:36
This adds 1 second to the current date and time, based on the local timezone.
Technical Details
- Works in MySQL versions: From MySQL 4.0.
- Return type: The function returns a
DATETIMEvalue representing the current local time.