Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7056917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:55:27+00:00 2026-05-28T03:55:27+00:00

Based on the first two answers, the question was unclear as originally posted, thus

  • 0

Based on the first two answers, the question was unclear as originally posted, thus I am completely rewriting it:

The following question is concerned only with how and what data is stored, and is no way shape or form concerned with converting data upon retrieval. As such, converting at SELECT to the desired time zone is not an appropriate answer.

When inserting a value into a timestamp with time zone field, it is retrieved (and thus presumably stored) with the timestamp converted to the local time zone of the database at the time it was inserted.

That is so say, a timestamp inserted as 2012-01-01 00:00:00+00:00 is retrieved as 2011-12-31 19:00:00-05, where the local time zone of the database at the time of the insert was -05. Timestamps that were inserted during daylight savings time, when the database was at -04, are returned using the -04 time zone.

What I want is for all timestamps to use an arbitrary time zone when stored (and thus all be retrieved without any additional work as having that time zone). That is to say, were the server orbiting the planet, all times would be at +00:00 (arbitrary time zone), instead of -12:00 to +12:00.

Can I insert into a timestamp with time zone column such that all timestamps are stored relative to an arbitrary time zone? If so, how?


Original follows.

When inserting a value into a timestamp with time zone field, it is being converted to the server’s current time zone.

Example: If I insert a value specifying a time zone of -1, retrieving it will give back the time at -5 (the time zone of the server at the time it was inserted).

Is it possible to specify that it should be stored using an arbitrary time zone?

Note: This question is not how to convert the returned time to another time zone, this is specific to how the time is stored.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:55:27+00:00Added an answer on May 28, 2026 at 3:55 am

    You have to save the time zone offset in addition to the timestamp.

    As @Milen already explained (and linked to the manual): a timestamp only saves a point in time (as abstract value). The time zone modifier is not saved, it only serves to adjust the timestamp relative to UTC.

    Consider the following demo:

    -- DROP TABLE tbl;
    CREATE TEMP TABLE tbl (id int, myts timestamptz, mytz interval);
    
    INSERT INTO tbl VALUES
     (1, now()                , EXTRACT (timezone from now()) * interval '1s')
    ,(2, '2012-01-01 00:00-05', interval '-5h')
    ,(3, '2012-01-01 00:00+04', interval '4h')
    ,(4, '2012-11-11 20:30+03', interval '3h');
    
    SELECT *
          ,(myts AT TIME ZONE mytz)::text
           || CASE WHEN mytz > '0:0' THEN '+' ELSE '' END
           || to_char(mytz, 'FMHH24:mi') AS timestamp_at_origin
    FROM tbl;
    

    Run it locally to see. Pay special attention to the details of the AT TIME ZONE construct, and how I extract the time zone from the (local!) timestamp with time zone.
    now() returns timestamp with time zone or timestamptz for short.

    EXTRACT (timezone from now()) * interval '1s'
    

    timestamp_at_origin displays the timestamp with time zone as seen at its origin. If I understood your question, then that is what you are looking for.
    You could further improve formatting.

    You may be interested in this related question which sheds some light on the ambiguities and pitfalls of time zones.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two dropdowns in extjs,based on the first dropdwon,the second dropdown populates.This is
I want to filter based on two attributes, the first is id and the
Doing my first SL4 MVVM RIA based application and i ran into the following
The first part of this question is actually a request for confirmation based on
This is a two part question: Part 1 First, dealing with calculating the entropy
First I want to make it clear that this is a homework based question.
UPDATE this question has evolved and was expanded, based on the answers given so
Following on from a previous question . Lets say I have two checkboxes on
I've two models: The first model: class Url < ActiveRecord::Base attr_accessible :code, :target, :user_id,
I want to sort results set first based on one column and then based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.