What's the easiest way to give a Time object representing a given time (say 5pm) on a given date (say 1/1/2010) in a given time zone (say EST)?
+3
A:
I'm a big fan of Time.parse, although Time.mktime is also an option:
Time.parse("1/1/2010 5:00pm EST") # => Fri Jan 01 17:00:00 -0500 2010
Time.mktime(2010, 1, 1, 17, 00) # => Fri Jan 01 17:00:00 -0500 2010
Note that Time.mktime always renders results using the local timezone, so Time.parse is more flexible in that regard.
tadman
2009-08-11 16:08:16