phrogz
1
From: Mike Nospam
I tried this already:
t = Time.at(1161275493444)
puts t
Resulting in:
Exception: bignum too big to convert into `long’
irb(main):001:0> Time.at( 1161275493444 / 1000 )
=> Thu Oct 19 10:31:33 -0600 2006
Time#at takes its argument as the number of seconds since the epoch, not
milliseconds.
You were close!
phrogz
2
Muchas gracias. I’ll RTFM closer…
irb(main):001:0> Time.at( 1161275493444 / 1000 )
=> Thu Oct 19 10:31:33 -0600 2006
Time#at takes its argument as the number of seconds since the epoch, not
milliseconds.
You were close!
phrogz
3
Mike Nospam wrote in post #157814:
Muchas gracias. I’ll RTFM closer…
irb(main):001:0> Time.at( 1161275493444 / 1000 )
=> Thu Oct 19 10:31:33 -0600 2006
Time#at takes its argument as the number of seconds since the epoch, not
milliseconds.
You were close!
Then, how to convert datetime to milliseconds in rails?
phrogz
4
On 04/25/2012 09:54 AM, Kuberan Gopal wrote:
Then, how to convert datetime to milliseconds in rails?
time = DateTime.now
=> Wed, 25 Apr 2012 10:23:55 +0200
time.strftime(“%L”).to_i
=> 329
time.strftime(“%3N”).to_i
=> 329