Borbat Borbat - 1 year ago 63
Ruby Question

'' not showing the right time

I want to use"%d/%m/%Y %H:%M")
to show the current time in my timezone, but it seems to be delayed for two hours. It shows:
28/08/2017 06:36
when it is
. How can I adjust the timezone to show the right time?

Answer Source

Pure Ruby Way:

>"+05:30").strftime("%d/%m/%Y  %H:%M")
#=> "28/08/2017  12:41"

where +05:30 (IST) is the offset of the particular zone

Note: will return your local zone

Using ActiveSupport:

>  require 'active_support/time'
#=> true 
>'US/Eastern').strftime("%d/%m/%Y  %H:%M")
#=> "28/08/2017  03:17"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download