0

I have a ruby-on-rails server that implements a JSON REST API e.g.

http://my-server.com/end_of_promotion.json

Currently, the answer is:

{
    date: "2013-03-31T14:29:16Z"
}

In my model, date is an attribute of type: datetime.

Now, I would like the client to display this date in the user timezone. How should I design the API and the client code to make it happen?

viebel
  • 19,372
  • 10
  • 49
  • 83

1 Answers1

2

Without more detail on your situation, here are some helpful resources.

For time zones on Rails, have a look here for the various options you can use: http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html

To format for your users, look into strftime. Docs: http://apidock.com/ruby/Time/strftime

A site that helps you generate strftime code: http://strftime.net/

A guide to I18n / internationalization: guides.rubyonrails.org/i18n.html (thanks @house9)

sscirrus
  • 55,407
  • 41
  • 135
  • 228