Skip to content

Instantly share code, notes, and snippets.

@kirkgo
Forked from rafarubert/gist:790860
Last active December 26, 2016 16:25
Show Gist options
  • Save kirkgo/2135863 to your computer and use it in GitHub Desktop.
Save kirkgo/2135863 to your computer and use it in GitHub Desktop.
Convert date format from brazilian portuguese to format accepted by database
def date=(date)
write_attribute(:date, date.gsub(/(\d{4})\/(\d{2})\/(\d{2})/, "#{$3}/#{$2}/#{$1}"))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment