Ruby / Rails 3: How to create a Date object from a Time object?
Given a Time object, say 2011-03-12 21:58:11 +1100, I would like to get the appropriate Date object (Sat, 12 Mar 2011).
What is the easiest way to achieve thi开发者_C百科s ?
Rails 3 extensions are welcome.
There's a to_date method for time that can be useful
Time.now.to_date
Looking at the 'Time' object documentation, you can simply use the to_date method.
date = your_time.to_date
加载中,请稍侯......
精彩评论