Tom
Tom

Reputation: 508

Makes the default time format to ISO8601

I'm developing an API only rails5 app. How can I make the default time format to iso8601? I don't wanna do something like time.iso8601 one by one.

Upvotes: 2

Views: 332

Answers (2)

Tom
Tom

Reputation: 508

I found a way to do it with active model serializer. https://github.com/rails-api/active_model_serializers/issues/582#issuecomment-49066700

Upvotes: 0

NM Pennypacker
NM Pennypacker

Reputation: 6942

You could do this with i18n. Add the file config/locales/en.yml (or whatever locale you're using by default) and add this to it:

en:
  date:
    formats:
      default: "%Y-%m-%d" # This is the same as ISO 8601

Upvotes: 1

Related Questions