My server is in US, rails default timezone is set to ‘UTC’, a user from India submits the form,Will rails convert that user’s time zone from India to UTC and save it in created_at column or it will save the UTC current time?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It will save the current time in UTC. Created_at and updated_at are Active Records internal timestamp columns, and as such they are never user input.
Also, basic security protocol dictates that you should never use the client’s time settings, always the servers.
Rails will do one thing though – it will use the webserver’s current time in UTC and store it in the database instead of the database servers current time.
By default, times are stored in UTC + offset format. When you specify the default timezone as lets say “Mumbai” it will return the datetime objects converted for that timezone.
You can also do: