I'm using strptime
to parse a date formatted in dd/mm/YYYY
format, however I just thought that simply parsing in this way will break i18n support, because if my customer is using a different language I will try to parse it in my format, while I want it to use date.formats.default
format in that function.
How to achieve this?
I solved my problem in this way:
Date.strptime(params[:date], I18n.translate('date.formats.default'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With