Pages

Monday, August 23, 2010

Ruby get time in milliseconds

Hi

If you want to get the current time in milliseconds in Ruby, type this following Ruby code.

Thanks to Antoine that show me the mistake ;-)

Time.now.to_f*1000

1 comment:

  1. This is false - to_f returns the time as the number of seconds since epoch. You need to multiply by 1000 to get the number of milliseconds.

    ReplyDelete