Firebase 如何比较颤振中以毫秒为单位节省的日期时间?
我在firebase中使用Firebase 如何比较颤振中以毫秒为单位节省的日期时间?,firebase,flutter,google-cloud-firestore,Firebase,Flutter,Google Cloud Firestore,我在firebase中使用.millissecondssinceepoch将日期时间保存为int值,例如dueDate=1613286572769,entryDate=161253000000。现在我想查询将来所有具有entryDate的项目,假设所有entryDate大于今天日期的项目 我正在做的是 todaysDate = DateTime.now().millisecondsSinceEpoch; carsCollection.orderBy('dueDate').limit(10).w
.millissecondssinceepoch
将日期时间保存为int值,例如dueDate=1613286572769
,entryDate=161253000000
。现在我想查询将来所有具有entryDate的项目,假设所有entryDate大于今天日期的项目
我正在做的是
todaysDate = DateTime.now().millisecondsSinceEpoch;
carsCollection.orderBy('dueDate').limit(10).where('entryDate', isGreaterThan: todaysDate).get();
这不是为我检索正确的项目。所有好人我都找到了答案。作为参考,我张贴它。 首先,您只需要找到今天的日期并将其转换
DateTime now = DateTime.now();
DateTime date = DateTime(now.year, now.month, now.day);
int convertedDate = date.millisecondsSinceEpoch;
下一个
carsCollection.orderBy('dueDate').limit(10).where('entryDate', isGreaterThan: convertedDate + 86400000 - 1).get();