w3resource

PostgreSQL LOCALTIMESTAMP() function

LOCALTIMESTAMP() function

The PostgreSQL LOCALTIMESTAMP() function is used to get the current date and time at the start of the current transaction.

Uses of LOCALTIMESTAMP() Function
  • Retrieve the current date and time without a time zone.

  • Obtain a consistent timestamp for the duration of the current transaction.

  • Useful in logging and auditing to capture the exact time a transaction started.

Syntax:

localtimestamp

Return Type: timestamp

PostgreSQL Version: 9.3

Pictorial Presentation of PostgreSQL LOCALTIMESTAMP() function

Pictorial presentation of PostgreSQL LOCALTIMESTAMP() function

Example: PostgreSQL LOCALTIMESTAMP() function

SELECT localtimestamp;

Sample Output:

        timestamp
-------------------------
 2015-01-15 14:02:56.925
(1 row)

N.B. - The outputs may change during the execution for the current date and time.

Previous: JUSTIFY_INTERVAL function
Next: NOW function



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/PostgreSQL/localtimestamp-function.php