Reputation: 5411
I have a date which is coming from the form in American format (MM-DD-YYYY) and now i want to compare it with the date from the database which is in utc.
And therefore i have to convert that date to utc,I'm doing this but its not working:
from_date = Date.strptime(params[:from_date], '%m-%d-%Y').utc
It is giving me error
undefined method `utc' for Sat, 15 Dec 2012:Date
Upvotes: 0
Views: 1401
Reputation: 1096
The #utc
method is only defined for Time objects. If timezones are important for what you are trying to do, try
from_date = Date.strptime(params[:from_date], '%m-%d-%Y').to_time.utc
Also look at the documentation: http://www.ruby-doc.org/core-1.9.3/Time.html#method-i-utc
Upvotes: 5