Seems like there should be an easy solution to this problem, yet I can't seem to find one.
Here is the issue: How do you assign a time zone to a Time object that results from a parsed date/time string? Example: - I receive a date time string from a date picker widget that does not include time zone info (i.e. "Mon May 11 18:24:37 2009"). - Time zone for this date is known and may be different than what's local to the user - date/time is stored in the DB as unix time (i.e. 1242075962) - time zone is stored in the DB in tz format i(i.e. 'America/ New_York') - I would like to be able to take a given date with its known time zone and calculate the equivalent unix time value. >> now = Time.now => Mon May 11 18:24:37 -0400 2009 >> now.to_i => 1242080677 >> parsed = DateTime.parse("Mon May 11 18:24:37 2009") => Mon, 11 May 2009 18:24:37 +0000 >> parsed.to_time => Mon May 11 18:24:37 UTC 2009 >> parsed.to_time.to_i => 1242066277 >> Time.at 1242066277 => Mon May 11 14:24:37 -0400 2009 It seems there should be a way to append the time zone to the string before it is parsed or to associate the parsed time with a time zone (without converting the time to the zone), however I can't seem to find an answer. Any help would be greatly appreciated --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---