Is there is any possibility in database, What ever time i am given which should store as GMT time stamp. If it so, Please share me.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
For PostgreSQL, your table should have a column of type
timestamp with time zone(timestamptzfor short) like this:If what you want to store (let’s call it
my_ts) is …a local
timestamp without time zone, i.e. it agrees with the current setting oftimezonein your client:Insert as is, everything is saved as UTC automatically internally:
a
timestamp with time zone:Insert as is, everything is saved as UTC automatically internally:
a
timestamp without time zonebut from another time zone:Say, you get
timestamp without time zonevalues from the Olympic Games in London, but your client thinks you are at a different time zone. Transform the timestamp with theAT TIME ZONEconstruct:If you use the time zone name (instead of a time zone abbreviation,
BSTin this case), DST (daylight saving time) rules are applied automatically. Details in this related question.More about timestamp handling in PostgreSQL in this related answer.
Now, if you want to display
tbl.tsas UTC (~ GMT)timestamp without time zone, regardless of your current time zone, retrieve the values like this:Note that
AT TIME ZONEhas a different effect when applied totimestamptzthan withtimestamp! Read the manual carefully.