ruby on rails - How to replace slashes with hyphens and change the place of the year and the day? -


i have birthday string field in format:

17/06/1989 

how can convert format using hyphens:

1989-06-17 

by using date parsing:

date.parse("17/06/1989").strftime("%y-%m-%d") 

or regex substitution:

"17/06/1989".gsub(/(..)\/(..)\/(....)/, '\3-\2-\1') 

Comments