# Converting unix\_t time to something rails understands

**URL:** <https://www.ruby-forum.com/t/converting-unix-t-time-to-something-rails-understands/133073>\
**Category:** Rails\
**Created:** [March 27, 2008, 1:20pm UTC](https://www.ruby-forum.com/t/converting-unix-t-time-to-something-rails-understands/133073 "2008-03-27T13:20:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ldk2005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d9b06d/32.png) [@ldk2005](https://www.ruby-forum.com/u/ldk2005)\
**Post date:** [March 27, 2008, 1:20pm UTC](https://www.ruby-forum.com/t/converting-unix-t-time-to-something-rails-understands/133073/1 "2008-03-27T13:20:25Z")

</div>

I have some data that I want to import into a table. The import file  
has  
dates in unix\_t time format ( seconds since 1970). How would I convert  
that  
to either a datetime value or a string? Is that a magic function  
somewhere?

–  
Best Regards,  
-Larry  
“Work, work, work…there is no satisfactory alternative.”  
— E.Taft Benson

---

<div class="post-metadata">

**Author:** ![ldk2005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d9b06d/32.png) [@ldk2005](https://www.ruby-forum.com/u/ldk2005)\
**Post date:** [March 27, 2008, 2:21pm UTC](https://www.ruby-forum.com/t/converting-unix-t-time-to-something-rails-understands/133073/2 "2008-03-27T14:21:36Z")

</div>

On Thu, Mar 27, 2008 at 05:19:24AM -0700, Larry K. wrote:

> I have some data that I want to import into a table. The import file has  
> dates in unix\_t time format ( seconds since 1970). How would I convert that  
> to either a datetime value or a string? Is that a magic function somewhere?

Time.at seconds\_since\_epoch

> Best Regards,  
> -Larry  
> –Greg

---

<div class="post-metadata">

**Author:** ![ldk2005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d9b06d/32.png) [@ldk2005](https://www.ruby-forum.com/u/ldk2005)\
**Post date:** [March 27, 2008, 5:48pm UTC](https://www.ruby-forum.com/t/converting-unix-t-time-to-something-rails-understands/133073/3 "2008-03-27T17:48:29Z")

</div>

Perfect!  
Thanks Greg,  
-Larry

On Thu, Mar 27, 2008 at 6:19 AM, Gregory S. \<  
removed\_email\_address@domain.invalid\> wrote:

> > Best Regards,  
> > -Larry  
> > –Greg
> 
> >

–  
Best Regards,  
-Larry  
“Work, work, work…there is no satisfactory alternative.”  
— E.Taft Benson
