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