我试图在 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();
我该如何解决这个问题,我也想知道如何将其转换为字符串以放入文本框。
最佳答案
Firestore 返回 Google.Cloud.Firestore.Timestamp
目的
如果我们将其转换为字符串看起来像:
Timestamp: 2021-04-03T10:34:48.865466Z
我们可以将其转换为
DateTime
目的:DateTime result = DateTime.ParseExact(TIMESTAMP.ToString().Replace("Timestamp:", "").Trim(),
"yyyy-MM-ddTHH:mm:ss.ffffffK", null);
关于c# - 我如何将 firestore 时间戳转换为不同的格式 en c#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66448972/