I know how to get the current utc_offset using Time.current.utc_offset
but how can I get it in the format "+hh:mm"?
The best solution I have so far is DateTime.now.to_s[-6,6]
strftime
with %z
(:
means hour and minute offset from UTC with a colon):
Time.current.strftime("%:z")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With