Ruby – Time

Prog #1
x = “1460041314”;
y = Integer(x);
puts “x is #{x.class}”;
puts “y is #{y.class}”;
#puts “z is #{z.class}”;
t = y;
t = Time.at(t).strftime(‘%Y %B %d %H:%M:%S:%L’);
puts “My time is #{t}”;

————–

Prog #2

x = “1460041314”;
z = “2016 April 07 15:01:54:000”;
def mytest(a)
begin

Time.at(Integer(a)).strftime(‘%Y %B %d %H:%M:%S:%L’);
rescue
puts “excaped”;
a;
end
end
puts “my time is #{mytest(z)}”;

Advertisements