PostgreSQL Tutorial

  • Home
  • Stored Procedures
  • Triggers
  • Views
  • Interfaces
    • PostgreSQL PHP
    • PostgreSQL Python
    • PostgreSQL JDBC
  • Functions
    • Aggregate Functions
    • Date / Time Functions
    • String Functions
    • Math Functions
Home / PostgreSQL Date Functions / PostgreSQL LOCALTIME Function

PostgreSQL LOCALTIME Function

The PostgreSQL LOCALTIME function returns the current time at which the current transaction starts.

Syntax

The syntax of the LOCALTIME function is as follows:

1
LOCALTIME(precision)

Arguments

The LOCALTIME function takes one optional argument:

1) precision

The precision argument specifies fractional seconds precision of the second field.

If you omit the argument, it defaults to 6.

Return Value

The LOCALTIME function returns a TIME value that represents the time at which the current transaction starts.

Examples

The following query illustrates how to get the time of the current transaction:

1
SELECT LOCALTIME;

Here is the result:

1
2
3
4
      time
-----------------
09:52:20.751278
(1 row)

The get the time with a specified fractional seconds precision, you use the following statement:

1
SELECT LOCALTIME(2);

The result is:

1
2
3
4
time
-------------
09:53:10.74
(1 row)

Remarks

Noted that the LOCATIME function returns a TIME value without time zone while the CURRENT_TIME function returns a TIME with time zone.

In this tutorial, you have learned how to use the PostgreSQL LOCALTIME function to get the time at which the current transaction starts.

Previous Tutorial: PostgreSQL DATE_PART Function
Next Tutorial: PostgreSQL LOCALTIMESTAMP Function

PostgreSQL Date Functions

  • AGE
  • CURRENT_DATE
  • CURRENT_TIME
  • CURRENT_TIMESTAMP
  • EXTRACT
  • LOCALTIME
  • LOCALTIMESTAMP
  • DATE_PART
  • DATE_TRUNC
  • NOW
  • TO_DATE
  • TO_TIMESTAMP

About PostgreSQL Tutorial

PostgreSQLTutorial.com is a website dedicated to developers and database administrators who are working on PostgreSQL database management system.

We constantly publish useful PostgreSQL tutorials to keep you up-to-date with the latest PostgreSQL features and technologies. All PostgreSQL tutorials are simple, easy-to-follow and practical.

Recent PostgreSQL Tutorials

  • How To Delete Duplicate Rows in PostgreSQL
  • PostgreSQL TO_CHAR Function
  • PostgreSQL TO_NUMBER Function
  • PostgreSQL TO_TIMESTAMP Function
  • PostgreSQL CEIL Function
  • PostgreSQL MOD Function
  • PostgreSQL FLOOR Function
  • PostgreSQL ABS Function
  • PostgreSQL TRUNC Function
  • PostgreSQL ROUND Function

More Tutorials

  • PostgreSQL Cheat Sheet
  • PostgreSQL Administration
  • PostgreSQL PHP
  • PostgreSQL Python
  • PostgreSQL JDBC
  • PostgreSQL Resources

Site Info

  • Home
  • About Us
  • Contact Us
  • Privacy Policy

Copyright © 2017 by PostgreSQL Tutorial Website. All Rights Reserved.