开发者

Storing a Timezone with Rails in PostgreSQL - what field type to use

I'm storing timezones in my database that I get via FB's api. The timezone looks like:

-开发者_JS百科7 

What field should I be using in rails/PostgreSQL to store this value? String?


If your timezone is always going to be an offset then use a :decimal (don't forget about places like Newfoundland Canada that are at UTC−3.5). Generally, timezones come in many different forms:

UTC-3.5
-7
America/Vancouver

So your safest bet would be a :string. The Olson Database is a good place to get an idea of the various timezone formats you'll come across.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜