Ruby Datetime parse -
i trying compare rows dates. first, saving data string date's this:
2/10/15 23:37 into postgresql db.
i can see date saved , looks this: 2015-02-10 23:37:00, , locale field set lc_collate = en_us.utf-8.
now using same file, , want compare date field, see if it's same (and should be!), ruby reads 2/10/15 23:37 0002-10-15 13:01:00 +0800.
i trying this:
date.strptime(mydate, "%m/%d/%y") but result 0015-02-12.
how can force ruby read input string same way db? trying set config.i18n.default_locale = 'en-us' in application.rb didn't help.
since you're supplying 2 digit year, should be:
date.strptime(mydate, "%m/%d/%y") # note lower case y if time important, should use:
datetime.strptime(mydate, "%m/%d/%y %h:%m")
Comments
Post a Comment