![]() In the above query, we changed the timezone value from “-01” to “+01” consequently, you will get the following output: The output shows that if the given timestamp contains a timezone, then the timezone() function shifts the original timestamp value to the specified time zone and retrieves the value without a time zone.įor a profound understanding, let’s change the timezone value in the specified timestamp: SELECT TIMEZONE('Australia/Melbourne', TIMESTAMP with TIME ZONE ' 10:00:00+01') ![]() Let’s pass a TIMESTAMP with timezone to the TIMEZONE() function and see how it works: SELECT TIMEZONE('Australia/Melbourne', TIMESTAMP with TIME ZONE ' 10:00:00-01') The “ pg_timezone_names” table contains all necessary details regarding Postgres-supported timezones.Įxample 1: How to Convert a TIMESTAMP(with timezone) to Another TIMESTAMP in Postgres? The output indicates that the current timezone is “America/Los_angeles”.Įxecute the “ SELECT *” command for the “ pg_timezone_names” table to see the list of all timezones supported by Postgres: SELECT * FROM pg_timezone_names To find the current timezone in PostgreSQL, you need to execute the following command: SHOW TIMEZONE How to Check the Current TIMEZONE in Postgres? Let’s put it into practice for a profound understanding! Here, tz represents a timezone based on which the given timestamp will be converted. As a result, it converts a timestamp to some other timestamp based on the zone specified within the timezone() function: timezone(tz, timestamp) In Postgres, the timezone() function accepts two values as arguments: a zone and a timestamp. How Does the TIMEZONE() Function Work in Postgres? ![]() This blog post will explain the working of the timezone() function with practical examples. The timezone() function does not change the value of the input timestamp instead, it simply retrieves a new timestamp with the same value but in a different time zone. PostgreSQL provides a built-in function named timezone() that converts a timestamp to a different time zone. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |