Convert PHP code into Ruby!
RSS icon Email icon Home icon
  • microtime

    Posted on May 17th, 2009 RubyLove No comments

    Returns 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