Now i facing the date format in my
database. I am using mysql as my database then the datetime format is
2008-06-04 15:17:55. But my datetime format is like this Fri May 23
16:43:28 +0800 2008. So when i execute it say incorrect datetime value.
how do i change the date_format or should i change the datatype to
string instead.
Actually i generate a scaffold in rails like these:
Now i facing the date format in my
database. I am using mysql as my database then the datetime format is
2008-06-04 15:17:55. But my datetime format is like this Fri May 23
16:43:28 +0800 2008. So when i execute it say incorrect datetime value.
how do i change the date_format or should i change the datatype to
string instead.
If you store date, the DateTime is the right format. Changing iit to
string isn’t a good idea.
temp = DateTime.parse(“Fri May 23 16:43:28 +0800 2008”)
should give you a valid DateTime object which you can assign to your db
column
Now how do i change the schema.rb attribute.
You don’t make changes in schema. If yo want to change something in your
db, just write another migration
Thanks a lot. But is there another way not to hard code
temp = DateTime.parse(“Fri May 23 16:43:28 +0800 2008”) as I am
retrieving emails in rails so the datetime will always change. is it a
way to format it to same as the internet email format. Thanks
I did not save in any variable as the datetime is i retrieved from
internet email and save it into a text file. So there isn’t any variable
assign to it. That why i do not what to do about changing the format of
the datetime. Hope there is someone who know it. Thanks
Wawa
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.