【发布时间】:2017-04-11 07:00:21
【问题描述】:
这就是我的代码的样子
cropref.child(mycrop.name).push({
cropname:mycrop.name,
croplocation:mycrop.location,
cropplantdate:mycrop.plantdate.toString(),
cropharvestdate:mycrop.harvestdate.toString(),
})
mycrop.harvestdate 和 mycrop.plantdate 都是来自我的 html 的日期输入
<input type="date" ng-model='mycrop.harvestdate'>
<input type="date" ng-model='mycrop.harvestdate'>
为了能够将数据放到我的 Firebase 数据库中,我需要先将其转换为字符串
cropplantdate:mycrop.plantdate.toString(),
但我的 Firebase 数据库中的数据包括时间和时区
样本数据
Sat Dec 12 2020 00:00:00 GMT+0800 (Malay Peninsula Standard Time)
所以一旦我从数据库中调用数据,我就无法过滤它,因为它不再是日期而是字符串。 我该如何解决这个问题,以便我可以过滤存储在我的数据库中的日期(转换为字符串)
【问题讨论】:
-
如果您坚持将日期存储为字符串,请将它们存储为按字典顺序按时间顺序排列的格式。例如。
2016-11-27T17:01:19。但更好的是:只需将时间戳存储为自纪元以来的毫秒数。见stackoverflow.com/questions/34957249/…
标签: angularjs firebase firebase-realtime-database angular-filters