ruby on rails - Losing information while converting Time.at(ts).in_time_zone(time_zone) to string -


while converting time in time zone string, loosing information need.

example:

ts = time.now.to_i time_zone = "america/los_angeles" time = time.now.in_time_zone(time_zone) time_string = time.to_s 

output:

time  #=> tue, 31 mar 2015 12:05:03 pdt -07:00 time_string  #=> "2015-03-31 12:05:03 -0700" 

how can time string equal tue, 31 mar 2015 12:05:03 pdt -07:00?

as engineersmnky said, strftime friend:

time_string = time_string.to_time.strftime("%a, %d %b %y %h:%m:%s pdt %z") 

but i'm not sure zone %z!


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -