【发布时间】:2021-06-01 13:29:25
【问题描述】:
我正在尝试在 c# 中的 dateTimePicker 值中添加时间戳,我不知道这是否可能,但我遇到了错误。如果可能的话,我想把它放在格式(“dd/MM/yyyy”)。
dateTimeDate.Value = student.date;
但我收到此错误,
Cannot implicitly pass the type "Google.Cloud.firestore.Timestamp" in "System.DateTime".
所以我试试这个,但还是不行。
dateTimeDate.Value = student.date.ToDateTime();
我该如何解决这个问题,我也想知道如何将其转换为字符串以放入文本框。
【问题讨论】:
-
好像dateTimeDate和student.date的类型不一样,可以去定义看看
-
你在使用
student.date.ToDateTime();时有没有报错? -
不,但我没有得到 Firestore 中的日期。出于某种原因,当我使用 student.date.ToDateTime () 时,我总是得到 01/01/1970。
-
不太清楚为什么您使用的数据类型未列为 firestore cloud.google.com/firestore/docs/concepts/data-types 支持的数据类型。您可能想改用日期和时间。您必须进行大量转换工作才能将 google.cloud.firestore.Timestamp 转换为 .net DateTime,因为它们使用完全不同的 epoch 值。
标签: c# firebase datetime google-cloud-firestore timestamp