如果用c#把当前时间转化为Discuz中的posttime,也就是mysql中的时间戳Timestamp
public static int DateToTimestamp(DateTime date)
{
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
TimeSpan diff = date - origin;
int timestamp = (int)Math.Floor(diff.TotalSeconds);
return timestamp;
}
public static DateTime TimestampToDate(double timestamp)
{
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
DateTime date = origin.AddSeconds(timestamp);
return date;
}
{
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
TimeSpan diff = date - origin;
int timestamp = (int)Math.Floor(diff.TotalSeconds);
return timestamp;
}
public static DateTime TimestampToDate(double timestamp)
{
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
DateTime date = origin.AddSeconds(timestamp);
return date;
}