.net 里把时间DateTime转成时间戳

 public string GenerateTimeStamp(DateTime dt)
        {
            // Default implementation of UNIX time of the current UTC time
            TimeSpan ts = dt.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            return Convert.ToInt64(ts.TotalSeconds).ToString();
        }


posted @ 2012-05-30 10:16  爱知菜  阅读(268)  评论(0编辑  收藏  举报