Convert a string date format from “17-Nov-2011” to “11/17/11”

后端 未结 3 974
太阳男子
太阳男子 2020-12-31 07:00

I have this code that converts an array of date strings from a format of 17-Nov-2011 to 11/17/11:

def date_convert dates
  months = { \'Jan\' => 1, \'Feb\         


        
3条回答
  •  青春惊慌失措
    2020-12-31 07:50

    Ruby has a pretty robust set of date and time functions, check out the Date class.

    Date.parse("17-Nov-2011").strftime('%m/%d/%y')
    

提交回复
热议问题