I have this jQuery function that returns the current time as the number of milliseconds since the epoch (Jan 1, 1970):
time = new Date().getTime
Javascript's gettime() returns the number of milliseconds since epoch.
Ruby's Time.now.to_i will give you the number of seconds since epoch. If you change that to Time.now.to_f, you still get seconds but with a fractional component. Just multiply that by 1,000 and you have milliseconds. Then use #to_i to convert it to an integer. And you end up with:
(Time.now.to_f * 1000).to_i