LOCALTIME is a non-deterministic scalar function defined by the SQL standard. It yields the session’s local time as a TIME value that has no time-zone component. The value is constant for the duration of the statement in which it appears, making repeated references within one query return the same result.Precision handling- Standard SQL allows an optional fractional-seconds precision: LOCALTIME or LOCALTIME(p). The precision p is an integer from 0 to the implementation’s maximum (commonly 6), controlling the number of decimal places in the seconds field.Session time zone impact- Although the function name implies “local,” the actual return is the time adjusted to the database session’s time-zone setting. If the session offset changes (via SET TIME ZONE in PostgreSQL, for example), LOCALTIME immediately reflects the new offset in subsequent statements.Side-effect characteristics- LOCALTIME has no arguments, causes no side effects, and is classified as an immutable function for the lifetime of a single statement but volatile across statements.Relation to other functions- LOCALTIME is similar to CURRENT_TIME but excludes a time-zone displacement portion. It differs from LOCALTIMESTAMP, which returns both date and time. In MySQL, LOCALTIME is a synonym for NOW(), returning a DATETIME value that includes the date; therefore behavior varies by dialect.Caveats- Not all engines support fractional precision or the function name exactly as specified. SQL Server, for example, lacks LOCALTIME entirely; developers must use GETDATE() or CONVERT.- Because LOCALTIME lacks a date component, combining it with date arithmetic requires explicit casting or concatenation in some dialects.
CURRENT_TIME, LOCALTIMESTAMP, CURRENT_DATE, NOW(), SYSDATE, GETDATE()
SQL-92 Standard
CURRENT_TIME returns a TIME WITH TIME ZONE in some systems, whereas LOCALTIME strips the time-zone offset and delivers a plain TIME value.
Yes. Provide an integer in parentheses, such as LOCALTIME(3), to get milliseconds if the dialect supports it.
MySQL defines LOCALTIME as a synonym for NOW(), which returns a DATETIME value; therefore it includes the date by design.
You cannot call LOCALTIME directly. Instead, use SELECT CAST(GETDATE() AS time); or the more precise SYSDATETIME() cast to TIME.