LOCALTIME
LOCALTIME is a SQL function used to retrieve the current date and time on the system. The result is displayed based on the local time zone of the system where the database is running.
LOCALTIME [( precision )]
- precision: This parameter specifies the number of fractional digits retained in the seconds field. The input can be an integer ranging between 0 and 6. If no precision parameter is provided, PostgreSQL will default to 0, meaning no fractional second digits are shown.
Example
Output
Explanation
The SQL command SELECT LOCALTIME;
is asking the database to return the current time where the server is located.
LOCALTIME()
Example
Output
Explanation
In the example, the SQL command LOCALTIME
returns the current time from the system’s time zone. The result is displayed in ‘HH:MM:SS’ format.
LOCALTIME()
Example
Output
Explanation
The LOCALTIME function is used to return the current date and time in the time zone of the current SQL session as set by the database. This was demonstrated in the example code with a fetch from the pseudo-table “dual”. The output is an example timestamp of the moment the function was called.