新手问题 如何快速的对比两个记录的时间戳是不是同一天

kikyous · July 18, 2012 · Last by quakewang replied at July 19, 2012 · 5859 hits

我现在是先比较天,然后比较年 recore.created_at.day recore.created_at.year

有没有什么对象就是以天为单位的?

就是比如 created_at: "2012-07-18 13:09:45"

只计 2012-07-18 忽略后面的时间

恩 to_date

忽略时间只比较年月日的话,取 yyyy-mm-dd 再直接拿字符串比较不就好了。

a.created_at.to_date == b.created_at.to_date

You need to Sign in before reply, if you don't have an account, please Sign up first.