Ruby Datetime parse
I am trying to compare strings by date. First, I store the data with the date string like this:
2/10/15 23:37
to my PostgreSQL database.
I can see that my date was saved and now looks like this: 2015-02-10 23:37:00
and the locale is set to lc_collate = en_US.UTF-8
.
Now I am using the same file and I want to compare the date field to see if it is equal (and it should be!), But Ruby reads 2/10/15 23:37
like 0002-10-15 13:01:00 +0800
.
I tried to do this too:
Date.strptime(myDate, "%m/%d/%Y")
But the result was 0015-02-12
.
How can I get Ruby to read my input line the same way as my DB? I tried to install config.i18n.default_locale = 'en-US'
.rb in my application but it didn't help.
source to share