Ognjen Regoje bio photo

MY NAME IS
Ognjen Regoje
BUT YOU CAN CALL ME OGGY


I make things that run on the web (mostly).
More /ABOUT me.

me@ognjen.io Twitter LinkedIn Instagram Github

Consistent display of dates in Rails

In order to consistently display dates in a Rails application the strftime format can be set globally.

#config/initializers/time_formats.rb

Date::DATE_FORMATS[:default] = "%d/%m/%Y"
Time::DATE_FORMATS[:default] = "%d/%m/%Y"

This makes the default .to_s of a DateTime to use strftime("%d/%m/%Y").

#rails #strftime #technical