【发布时间】:2016-03-18 22:31:22
【问题描述】:
我正在尝试过滤 Realm 对象以查找日期少于一年前的 createdAt 对象:
let datex = NSCalendar.currentCalendar().startOfDayForDate(NSDate()).dateByAddingTimeInterval(-1*365*24*60*60)
let list = RealmDB.objects(TaskList).filter("createdAt <= '\(datex)'")
我收到以下错误:
类型为“TaskList”的对象的属性“createdAt”的预期类型为日期对象,但收到:“2015-03-19 21:00:00 +0000”
我该如何解决这个问题?看起来日期和时间值也已调整为时区。如何确定日期真的是一天的结束?
【问题讨论】: