如果用c#把当前时间转化为Discuz中的posttime,也就是mysql中的时间戳Timestamp

 public static int DateToTimestamp(DateTime date)
        {
            DateTime origin = new DateTime(1970110000);
            TimeSpan diff = date - origin;
            int timestamp = (int)Math.Floor(diff.TotalSeconds);
            return timestamp;
        }

        public static DateTime TimestampToDate(double timestamp)
        {
            DateTime origin = new DateTime(1970110000);
            DateTime date = origin.AddSeconds(timestamp);
            return date;
        }
posted @ 2012-04-06 14:05  PointNet  阅读(1225)  评论(0编辑  收藏  举报