【发布时间】:2018-07-23 06:40:10
【问题描述】:
type="date" 在 html 中保存为 firestore 中的字符串。
在 html 文件中。
<input #scheduledStartDate="ngModel" [(ngModel)]="reposition.scheduledStartDate"
name="scheduledStartDate" id="scheduledStartDate" class="input is-normal"
type="date" required placeholder="Leaving...">
来自接口 .ts 文件
scheduledStartDate?: DateTimeFormat;
也试过了
scheduledStartDate?: Date;
同样的结果。
这两个选项都将输入的日期值保存为 Firestore 中的字符串,例如“2018-01-02”而不是时间戳。
【问题讨论】:
-
你能提供一些示例代码吗?
-
你找到方法了吗?
-
如果您使用 Firestore 控制台创建文档并选择
timestamp作为字段类型,它将保存为 ISO8601 字符串。此外,文档的createTime和updateTime参数也以这种格式存储。因此,除非您有非常具体的要求将该日期存储为 Linux/Unix 时间戳,否则我建议您坚持使用当前格式。
标签: angular google-cloud-firestore