I have date in this format month/day/year. How i can convert this date to actual timestamp. in ruby on rails.
e.g.
date = 6/21/2021
CodePudding user response:
I think you just need format that string to valid format to convert to date, something like this:
old_format = '6/21/2021'.split('/')
old_format[0], old_format[1] = old_format[1], old_format[0]
old_format.join('/').to_date