Menu

MariaDB LOCALTIME(): Current Date and Time

Updated on

MariaDB LOCALTIME returns the current date and time in the current session time zone. It is a synonym for NOW(); you can write it with or without parentheses.

Syntax

LOCALTIME
LOCALTIME()
LOCALTIME([precision])

The optional precision controls fractional-second precision from 0 to 6 digits. If omitted, the default is 0.

Examples

These forms return the current date and time. A precision argument requests that many fractional-second digits:

SELECT LOCALTIME,
       LOCALTIME(),
       LOCALTIME(3),
       LOCALTIME(6);
LOCALTIME            LOCALTIME()          LOCALTIME(3)             LOCALTIME(6)
-------------------  -------------------  ------------------------  ---------------------------
2023-01-10 11:23:17  2023-01-10 11:23:17  2023-01-10 11:23:17.258  2023-01-10 11:23:17.258504

The value uses the current session time zone. Check or change it using MariaDB’s time zone settings.

In a numeric context, MariaDB formats the value as YYYYMMDDHHMMSS.uuuuuu:

SELECT LOCALTIME + 0;

For precision details, see Microseconds in MariaDB. For alias and return-type behavior, see NOW().