0

I have developed online examination system, and while creating exam i submit "exam start time", this is stored in the database as UTC,

for example say exam start time "Sun Jan 29 15:30:00 UTC 2012",

Student from India should see the exam start time in his local time i.e "Sun Jan 29 21:00:00 +0530 2012"

Student from France should see the exam start time in his local time,

please guide me how i can acheive this,

Thanks in advance

lamrin
  • 1,431
  • 4
  • 22
  • 34

2 Answers2

0

Before I read this thread on Stackoverflow I used the information from another SO thread to resolve this one:

new Date().getTimezoneOffset()/60;

It is a javascript function but can easily be put in application.html.erb or elsewhere if you want a less obtrusive form.

Community
  • 1
  • 1
ScottJShea
  • 7,041
  • 11
  • 44
  • 67
0

If you already know where the student is from, you can use: http://api.rubyonrails.org/classes/ActiveSupport/TimeWithZone.html#method-i-in_time_zone

Otherwise, go with Scott's suggestion.

Wilhelm
  • 820
  • 8
  • 10