# Problems with the use of time in the migration

**URL:** <https://www.ruby-forum.com/t/problems-with-the-use-of-time-in-the-migration/142777>\
**Category:** Rails\
**Created:** [July 11, 2008, 11:51am UTC](https://www.ruby-forum.com/t/problems-with-the-use-of-time-in-the-migration/142777 "2008-07-11T11:51:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JolSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b19c9b/32.png) [@JolSSSS](https://www.ruby-forum.com/u/JolSSSS)\
**Post date:** [July 11, 2008, 11:51am UTC](https://www.ruby-forum.com/t/problems-with-the-use-of-time-in-the-migration/142777/1 "2008-07-11T11:51:57Z")

</div>

Hi!

I created a table like this:

create\_table :work\_items do |t|  
t.date :execution\_date  
t.string :section  
t.integer :member\_id  
t.time :duration  
t.text :description

t.timestamps  
end

I need the duration field to enter something like HH:MM. Just the time  
without a date.

When I enter it, everything seems fine… But when I return to the  
edit view I see the time formatted like 2000-01-01 10:23:00…

When I create a validate method in the model to check on the input, I  
allways get 2000-01-01 10:23:00, weird because I only entered 10:23…

This is the validate method in the model:

]def validate  
puts duration # Results in 2000-01-01 10:23:00  
end

Can anyone help me? I hoped time would work like date, with this  
column I don’t have any problems…

Thhnx!

---

<div class="post-metadata">

**Author:** ![JolSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b19c9b/32.png) [@JolSSSS](https://www.ruby-forum.com/u/JolSSSS)\
**Post date:** [July 11, 2008, 7:11pm UTC](https://www.ruby-forum.com/t/problems-with-the-use-of-time-in-the-migration/142777/2 "2008-07-11T19:11:34Z")

</div>

On 11 Jul 2008, at 10:51, Jolé wrote:

> t.text :description  
> When I create a validate method in the model to check on the input, I  
> allways get 2000-01-01 10:23:00, weird because I only entered 10:23…

Ruby doesn’t have a pure time of day class. Just don’t display the non  
time of day bit. (eg use time\_select instead of datetime\_select for  
editing and so on)

Fred
