1

I need to get the current timezone but Time.now.zone only has options for the abbreviation. Poked around in the docs and couldn't find anything useful. Is this possible?

orde
  • 5,233
  • 6
  • 31
  • 33
Niko
  • 984
  • 1
  • 7
  • 15
  • I don't think this functionality is built into the ruby language. If you are using rails you could call `Time.zone.name` however. – Andy Stabler Feb 16 '18 at 17:19
  • What OS are you using? On Win, I see that it returns full name; on Ubuntu, it's abbreviated. – orde Feb 16 '18 at 17:21
  • @orde ah yeah that's what it is I'm on Ubuntu. I think at this point it's easiest to just make a mapping of gmt offset --> full name. – Niko Feb 16 '18 at 17:27
  • No, you cannot make that mapping. See "time zone != offset" in [the timezone tag wiki](https://stackoverflow.com/tags/timezone/info). – Matt Johnson-Pint Feb 16 '18 at 18:18

1 Answers1

0

You forgot to add Time.now.getlocal.zone. This should work.

DishMaster
  • 11
  • 3