PHP to Ruby
Convert PHP code into Ruby!
-
time
Posted on May 20th, 2009 No commentsReturns the current Unix timestamp (epoch).
PHP
echo time(); // => 1242744141
Ruby
puts Time.now.to_i; # => 1242744141
-
microtime
Posted on May 17th, 2009 1 commentReturns the current Unix timestamp (epoch) with microseconds.
PHP
echo microtime(); // => 0.63928794 1242744141
Ruby
epoch_mirco = Time.now.to_f; epoch_full = Time.now.to_i; epoch_fraction = epoch_mirco - epoch_full; puts epoch_fraction.to_s + ' ' + epoch_full.to_s; # => 0.639287948608398 1242744141


