How to_timestamp() Works in PostgreSQL

According to the PostgreSQL documentation, there are two functions called to_timestamp():

  • One converts the Unix epoch to a timestamp. The Unix epoch is the number of seconds since 1970-01-01 00:00:00+00.
  • The other converts a string to a timestamp.

More specifically, each function converts the value to a timestamp with time zone value.

Although the Postgres documentation presents them as two separate to_timestamp() functions, I present them as if they’re one function that accepts either one argument, or two.

Read more

Return a List of Timezones Supported by PostgreSQL

When working with PostgreSQL, you may occasionally find yourself in the situation where you need a list of timezones that Postgres recognises.

For example, you could be trying to set the timezone for your current session, or you could be using one of the datetime functions that allow you to manipulate the timezone.

Below are two views and two functions that return a list of timezones.

Read more