문제

I am trying to convert Datetime: http://msdn.microsoft.com/en-us/library/03ybds8y

to the number of seconds since 1970 using Visual C++.

I searched many solutions but could not make any of them work. Thanks

도움이 되었습니까?

해결책

You can do this using a TimeSpan of the difference between the two dates. Something like this:

DateTime dtDateYouWantToConvert = /* .... */
DateTime dtReference(1970, 1, 1, 0, 0, 0);

TimeSpan tsDiff = dtDateYouWantToConvert - dtReference;

// calculate number of seconds (including fractional) since 1/1/1970
double dSeconds = tsDiff.TotalSeconds;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top