MariaDB LOCALTIME() Function
In MariaDB, LOCALTIME() is a built-in function that returns the current date and time.
The LOCALTIME() function is exactly the same as NOW() and CURRENT_TIMESTAMP().
MariaDB LOCALTIME() Syntax
This is the syntax of the MariaDB LOCALTIME() function:
LOCALTIME
LOCALTIME([precision])
Parameters
precision-
Optional. The precision of fractional seconds. From 1 to 6.
Return value
MariaDB LOCALTIME() returns the current date and time.
If in a string context, LOCALTIME() returns the current date and time in the YYYY-MM-DD HH:MM:SS format, and it returns the current date and time in YYYYMMDDHHMMSS.uuuuuu format if in a numeric context.
MariaDB LOCALTIME() Examples
Example 1
The following statement shows the basic usage of the MariaDB LOCALTIME() function:
SELECT
LOCALTIME,
LOCALTIME(),
LOCALTIME(3),
LOCALTIME(6)\G
Output:
LOCALTIME: 2023-01-10 11:23:17
LOCALTIME(): 2023-01-10 11:23:17
LOCALTIME(3): 2023-01-10 11:23:17.258
LOCALTIME(6): 2023-01-10 11:23:17.258504Example 2 - Numeric Context
When used in a numeric context, the resulting datetime is in the YYYYMMDDHHMMSS.uuuuuu format.
SELECT
LOCALTIME,
LOCALTIME + 0,
LOCALTIME(6) + 0\G
Output:
LOCALTIME: 2023-01-10 11:23:30
LOCALTIME + 0: 20230110112330
LOCALTIME(6) + 0: 20230110112330.037360Conclusion
In MariaDB, LOCALTIME() is a built-in function that returns the current date and time.