How do I get the abbreviation from the timezone instead of the clock offset from strftime?

I know there are many timezones that use the same offsets from UTC / GMT. When using strftime ('% Z'), it returns the offset in hours / minutes.

Does anyone know of an easy way to get the timezone as a string with 3 characters of the timezone, for example. +0100 => CET

I have defined my own date format in my time_formats.rb initializer

Time::DATE_FORMATS[:friendly_datetime] = '%A, %-d %B %Y at %H:%M %Z'

This gives: Sunday, 11 January 2015 at 20:00 +0100

I would like% Z (+0100) to be CET. I was thinking about making my own hash translation and using proc in my custom time format. I kind of hoped there was a built-in way, or maybe a gem that I don't know about.

+3
ruby ruby-on-rails


source to share


No one has answered this question yet

Check out similar questions:

1023
How do I get the current absolute url in Ruby on Rails?
771
How to get a random number in Ruby
510
How can I remove a key from a Hash and get the remaining hash in Ruby / Rails?
17
Rails times oddness: "x days from now"
4
Time is played out in ruby ​​at arbitrary offset gmt
1
Working with ActiveRecord when working with daylight saving time
1
How can I convert Time from some timezone to UTC with daylight saving time in mind in Ruby?
0
Rails UTC displays date to custom
0
How to set up time intervals in Ruby for each element saved by the user
0
Rails gem time_ago - how to change timezone to UTC +00: 00 London?



All Articles
Loading...
X
Show
Funny
Dev
Pics