# Re: How to convert long/milliseconds to DateTime?

**URL:** <https://www.ruby-forum.com/t/re-how-to-convert-long-milliseconds-to-datetime/73483>\
**Category:** Ruby\
**Created:** [October 24, 2006, 9:19pm UTC](https://www.ruby-forum.com/t/re-how-to-convert-long-milliseconds-to-datetime/73483 "2006-10-24T21:19:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 24, 2006, 9:19pm UTC](https://www.ruby-forum.com/t/re-how-to-convert-long-milliseconds-to-datetime/73483/1 "2006-10-24T21:19:29Z")

</div>

From: Mike Nospam

> Java developer making the switch.

Welcome!

> I have timestamps stored in Oracle as  
> a long (gotten from java.sql.Timestamp - milliseconds from  
> some day in  
> 1970). Is there a way to convert that long back into a Ruby  
> Date/DateTime/Time . Any of these would do.

ri Time.at

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 24, 2006, 9:42pm UTC](https://www.ruby-forum.com/t/re-how-to-convert-long-milliseconds-to-datetime/73483/2 "2006-10-24T21:42:52Z")

</div>

Thanks Gavin. I did a lot of Smalltalk programming in the 90’s, so Ruby  
has a familiar, fun feel.

I tried this already:

t = Time.at(1161275493444)  
puts t

Resulting in:  
Exception: bignum too big to convert into `long’

No joy. Am I missing something (else)?

Thanks,

Mike

Gavin K. wrote:

> From: Mike Nospam
> 
> > Java developer making the switch.
> 
> Welcome!
> 
> > I have timestamps stored in Oracle as  
> > a long (gotten from java.sql.Timestamp - milliseconds from  
> > some day in  
> > 1970). Is there a way to convert that long back into a Ruby  
> > Date/DateTime/Time . Any of these would do.
> 
> ri Time.at

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 24, 2006, 9:57pm UTC](https://www.ruby-forum.com/t/re-how-to-convert-long-milliseconds-to-datetime/73483/3 "2006-10-24T21:57:54Z")

</div>

On Wed, 25 Oct 2006, Mike Nospam wrote:

> Thanks Gavin. I did a lot of Smalltalk programming in the 90’s, so Ruby  
> has a familiar, fun feel.
> 
> I tried this already:
> 
> t = Time.at(1161275493444)  
> puts t

irb(main):003:0\> Time.at(1161275493444 / 1000.0)  
=\> Thu Oct 19 11:31:33 CDT 2006

Kirk H.
