Advertisement
Guest User

Untitled

a guest
Jul 30th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.51 KB | None | 0 0
  1. # I want to get the GMT time in the rfc1123 format (Tue, 15 Nov 1994 08:12:31 GMT)
  2. # Here is what I do
  3.  
  4. # getting GMT time
  5. 1.9.3-p429 :063 > datetime = DateTime.now.new_offset(0)
  6.  => #<DateTime: 2013-07-30T10:34:52+00:00 ((2456504j,38092s,886243436n),+0s,2299161j)>
  7. # but this below returns the local time :/
  8. 1.9.3-p429 :064 > datetime = DateTime.now.new_offset(0).to_time
  9.  => 2013-07-30 12:34:59 +0200
  10. 1.9.3-p429 :065 > puts datetime.strftime("%a, %d %b %Y %H:%M:%S")
  11. Tue, 30 Jul 2013 12:34:59 # <-- wrong..
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement