gpt4 book ai didi

c# - 在 .net 中解析作为 JSON 返回的日期?

转载 作者:行者123 更新时间:2023-11-30 16:25:13 25 4
gpt4 key购买 nike

您好,我正在接收来自 API 的 JSON 响应并将其加载到我的应用程序中。除了特定项目发布的日期外,一切都可以正常导入。日期返回为我以前从未使用过的数字:

'date_created' : 1279643054

我尝试使用普通的 DateTime.Parse() 但没有成功。有谁知道如何解析这个,或者如果有的话,这种格式的名称是什么,以便我可以做进一步的研究?谢谢。

最佳答案

这是一个UNIX Timestamp .使用此代码将时间戳转换为 DateTime 对象:

static DateTime ConvertFromUnixTimestamp(long timestamp)
{
return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(timestamp);
}

关于c# - 在 .net 中解析作为 JSON 返回的日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10143678/

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