The first thing that comes to mind for me is:
DateTime.now.new_offset('+5:00').strftime('%F %T %z')
You'll have to require 'date'
first.
Question
I have a Ruby process that makes a log file:
operation completed at #{Time.now}
This generates a log file that contains:
operation completed at 2014-04-23 01:51:16 +0200
But the Ruby process runs on a server that is far from me, and I have another timezone. I have +05 timezone, and I want to see:
2014-04-23 03:51:16 +0500
What I should write instead of #{Time.now}
?
Solution
The first thing that comes to mind for me is:
DateTime.now.new_offset('+5:00').strftime('%F %T %z')
You'll have to require 'date'
first.