LOCALTIME
LOCALTIME [( precision )]
Section titled “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
Section titled “Example”SELECT LOCALTIME;Output
Section titled “Output”15:26:43.449135Explanation
Section titled “Explanation”The SQL command SELECT LOCALTIME; is asking the database to return the current time where the server is located.
LOCALTIME()
Section titled “LOCALTIME()”Example
Section titled “Example”SELECT LOCALTIME AS CurrentTime;Output
Section titled “Output” CurrentTime-------------------- 12:24:35Explanation
Section titled “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()
Section titled “LOCALTIME()”Example
Section titled “Example”SELECT LOCALTIME FROM dual;Output
Section titled “Output”10:30:15.123456Explanation
Section titled “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.