Reputation: 4420
I have a problem. I want to store current date+ time in my database. I was trying to make a migration like
current_time:date
and
current_time=DateTime.now
but it stores current date only, also i was trying to do
current_time:time
in migration. and then
current_time=Time.now
or
current_time=DateTime.now
But it stores only current time, another parametres are 2000-01-01. What I am doing wrong?
Thanks in advance.
Upvotes: 3
Views: 1011
Reputation: 8954
Use timestamp
in your migration. Of cause date
only stores dates and time
only stores time but timestamp
stores the secounds since the 01.01.1970 00:00 and that an absolute time definition.
current_time:timestamp
To add some days you can do
instance.current_time+=3.days
Upvotes: 3