These code is to read the email i save in the text file that i have
retrieved from gmail.
msisdn = ""
datetime = ""
date = ""
File.open(Pathname.new(ARGV[0]), ''r'') do |mbox|
  RMail::Mailbox.parse_mbox(mbox) do |raw|
    count += 1
    print "Mail #{count}\n"
    message = RMail::Parser.read(raw)
    msisdn = message.header[''From'']
    datetime = message.header[''Date'']
When i do
    date = DateTime.parse(datetime)
 the result is 2008-06-05T08:45:58+00:00
But i only want the format to be 2008-06-05 08:45:58 because only these
match the mysql datetime format. Is there other way of do the parsing?
Thanks
Wawa
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Emmie Wawa wrote: <snip>> But i only want the format to be 2008-06-05 08:45:58 because only these > match the mysql datetime format. Is there other way of do the parsing? > Thanks > > Wawa<snip> You can output the datetime in any format you desire using the strftime method. Off the top of my head, something like this may do the trick: date.strftime(''%Y-%m-%d %H:%M:%S) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
for usage in db you can do: date.to_s(:db) this will output any DateTime for use with SQL -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---