Unix Timestamp와 .NET DateTime 간의 상호변환

Posted 2008/05/09 14:13 by 길버트

Unix Timestamp를 .NET DateTime으로 변환할 때

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

.NET DateTime을 Unix Timestamp로 변환할 때

static int ConvertToUnixTimestamp(DateTime date)
{
    DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
    TimeSpan diff = date - origin;
    return (int)Math.Floor(diff.TotalSeconds);
}

참고 : http://codeclimber.net.nz/archive/2007/07/10/Convert-a-Unix-timestamp-to-a-.NET-DateTime.aspx

Tag : .net, C#, datetime, unix timestamp

코멘트를 남겨 주세요. (Write your message and submit)
사용자 삽입 이미지

실버라이트 개발팀도 이끌고 있다고 하죠?

1월 17일 오후 1:30 코엑스 컨퍼런스 센터 310호입니다.

세미나 등록하러 가기
이올린에 북마크하기(0) 이올린에 추천하기(0)

Tag : .net, MSDN 세미나, ScottGu, 김국현, 실버라이트

  1. BlogIcon 테디

    정말 가고 싶은 세미나인데.. 모옷~ 가아 !! ~효

    | 2008/01/16 15:00 | PERMALINK | EDIT | REPLY |
코멘트를 남겨 주세요. (Write your message and submit)