gpt4 book ai didi

c# - 我如何将 firestore 时间戳转换为不同的格式 en c#

转载 作者:行者123 更新时间:2023-12-04 08:01:22 25 4
gpt4 key购买 nike

我试图在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com