I'm looking for the best practice solution.
Take for example stackoverflow and a question I asked :
I live in Israel , and now the time is :
I did ask something at ~17:58 ( 3 hours before now)
Yet , it does show "3 hours ago" AND display UTC time . ( Israel is +2)
So either it saves both UTC and my offset
or it saves just UTC and in JS at client side it showes me the local time.
now my question is from a DB point of view :
I can detect from where the client has connected via JS command :
new Date().getTimezoneOffset(); //-120
I could store it like :
data | UTCTime | userOffset
----------------------------------------
... 2012-12-24 15:36:31 -2
Question
Is this the best solution of storing world wide events (datetimes) ?
In c# there is a DateTimeOffset
Structure type which store the offset inside it .
is there any equivalent solution in Sql server ?
According to this post: you should always keep your date unified. So UTC would be the best choice.
On the other hand - when you have date in UTC you can easily show it right according to someones timezone (not only for the author, but for everybody).