The LOCALTIME() function returns the current date and time as a string YYYY-MM-DD hh:mm:ss or numerically as BIGINTYYYYMMDDhhmmss or as DECIMALYYYYMMDDhhmmss.microseconds, depending on whether the function is used in string or numeric context.
The value is expressed in the format of the current session time zone.
The "Precision" argument can be specified to indicate a sub-second precision from 0 to 6 digits.
The specification of "Precision" must be a written number from 0-6. Expressions or variables produce a syntax error, larger values produce a precision error.
Unlike the NOW() function, this function can omit the parentheses if "Precision" is not specified.
Setting the system variable timestamp takes affect to the function LOCALTIME() in contrast to then SYSDATE() function.
errno: 1426 sqlstate: 42000 error: Too big precision 7 specified for 'current_timestamp'. Maximum is 6
selectlocaltime(3 + 2)
errno: 1064 sqlstate: 42000 error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '+ 2)' at line 1
selectlocaltime(@a)
errno: 1064 sqlstate: 42000 error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '@a)' at line 1
Examples of how setting the system variable timestamp affects
The examples were created with the MyWAY SQL manager: Download
How to use the LOCALTIME() function in MySQL and MariaDB databases
In MySQL and MariaDB the LOCALTIME() function is used to get the current date and time. The function returns the current timestamp in the format "YYYY-MM-DD HH:MM:SS". LOCALTIME() can be used to get current date and time in SQL queries, as default value for timestamp columns in tables, in timezone consideration or in various calculations or manipulations with timestamps using functions that add or subtract time intervals from the current timestamp value.