i want to calculate time difference in minutes between two date_time fields.like created_at and updated_at kind of fields. i want the result like this updated_at - created_at = some minutes.
these times are present in time zone of INDIA. how can i do that in rails?
created = article.created_at
updated = article.updated_at
minutes = updated - created
This solution works for ActiveRecord models using TimeWithZone
classes for created_at
and updated_at
.
created = article.created_at
updated = article.updated_at
minutes = (updated - created) / 1.minutes