I have this jQuery function that returns the current time as the number of milliseconds since the epoch (Jan 1, 1970):
jQuery
time = new Date().getTime
Get a Time object with Time.now, calling #to_i returns a Unix timestamp (seconds from epoch). #to_f gives fractional seconds which you can use to get milliseconds from epoch:
Time.now
#to_i
#to_f
Time.now.to_f * 1000