How to convert long/milliseconds to DateTime?

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! :slight_smile:

ยทยทยท

From: Mike Nospam

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! :slight_smile:

--
Posted via http://www.ruby-forum.com/\.

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! :slight_smile:

Then, how to convert datetime to milliseconds in rails?

ยทยทยท

--
Posted via http://www.ruby-forum.com/\.

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

ยทยทยท

On 04/25/2012 09:54 AM, Kuberan Gopal wrote:

--
Lars Haugseth