如何知道图片在instragram中的发布时间

本文关键字:布时间 时间 何知道 instragram | 更新日期: 2023-09-27 18:21:20

我正在尝试用C#获取图片instagram的发布时间
例如,我从服务器获得了下一个字符串(JSON):
{"created_time":"1447156299","text":".........}
几点了?

如何知道图片在instragram中的发布时间

您可以按如下方式执行:

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

你必须通过"1447156299"加倍,然后你才能做到。

有关更多信息,请查看本教程

编辑

// This is an example of a UNIX timestamp for the date/time 11-04-2005 09:25.
double timestamp = 1113211532;
// First make a System.DateTime equivalent to the UNIX Epoch.
System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
// Add the number of seconds in UNIX timestamp to be converted.
dateTime = dateTime.AddSeconds(timestamp);
// The dateTime now contains the right date/time so to format the string,
// use the standard formatting methods of the DateTime object.
string printDate = dateTime.ToShortDateString() +" "+ dateTime.ToShortTimeString();
// Print the date and time
System.Console.WriteLine(printDate);

取自此站点

输出1113211532UNIX timestamp

2005年4月11日上午9:25

输出1447156299UNIX timestamp

2015年10月11日上午11:51