Parse a date in rails

后端 未结 2 1684
眼角桃花
眼角桃花 2020-12-10 01:06

I have a date (Which is actually parsed from a PDF) and it could be any of the following format:

MM/DD/YYYY
MM/DD/YY
M/D/YY
October 15, 2007
Oct 15, 2007 
         


        
2条回答
  •  囚心锁ツ
    2020-12-10 01:25

    I find the chronic gem very easy to use for time parsing and it should work for you. i tried the examples you gave.

    https://github.com/mojombo/chronic

提交回复
热议问题