user-0 提问: tm  time_t 转化的问题

回复:
user: user-1
content: FILETIME The FILETIME structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601.   typedef struct _FILETIME { // ft      DWORD dwLowDateTime;      DWORD dwHighDateTime;  } FILETIME;    Members dwLowDateTime  Specifies the low-order 32 bits of the file time.  dwHighDateTime  Specifies the high-order 32 bits of the file time.  Remarks It is not recommended that you add and subtract values from the FILETIME structure to obtain relative times. Instead, you should   Copy the resulting FILETIME structure to a LARGE_INTEGER structure.  Use normal 64-bit arithmetic on the LARGE_INTEGER value.  QuickInfo   Windows NT: Requires version 3.1 or later.   Windows: Requires Windows 95 or later.   Windows CE: Requires version 1.0 or later.   Header: Declared in winbase.h.  See Also Time Overview, Time Structures, CompareFileTime, GetFileTime, LARGE_INTEGER      Time Functions The following functions are used with time.        CompareFileTime   DosDateTimeToFileTime   FileTimeToDosDateTime   FileTimeToLocalFileTime   FileTimeToSystemTime   GetFileTime   GetLocalTime   GetSystemTime   GetSystemTimeAdjustment   GetSystemTimeAsFileTime   GetTickCount   GetTimeZoneInformation   LocalFileTimeToFileTime   SetFileTime   SetLocalTime   SetSystemTime   SetSystemTimeAdjustment   SetTimeZoneInformation   SystemTimeToFileTime   SystemTimeToTzSpecificLocalTime

user: user-2
content: 因为和你时区有关

user: user-3
content: 了解一下。。。。

user: user-1
content: 学习这些Windows Time相关的API的用法。

user: user-1
content: 或者参考这个：#include <afxdisp.h> #include <stdio.h> #include <stdlib.h> int main(int argc, TCHAR* argv[]) {     COleDateTime t;     COleDateTimeSpan ts;     CString s,fmt;     int nYear;     int nMonth;     int nDay;     int nHour;     int nMin;     int nSec;     int lDays;     int nHours;     int nMins;     int nSecs;     int i,N;     // initialize MFC and print and error on failure     if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) {         printf("Fatal Error: MFC initialization failed\n");         return 1;     }     if (argc<13) {         printf("Usage:%s sYYYY sMM sDD shh smm sss pDD phh pmm pss n {SQL|YYYY|YY}\n",argv[0]);         return 2;     }     if (stricmp(argv[12],"SQL")==0) fmt="%Y-%m-%d %H:%M:%S";     else if (stricmp(argv[12],"YYYY")==0) fmt="%Y%m%d %H%M%S";     else if (stricmp(argv[12],"YY")==0) fmt="%y%m%d %H%M%S";     else {         printf("Usage:%s sYYYY sMM sDD shh smm sss pDD phh pmm pss n {SQL|YYYY|YY}\n",argv[0]);         return 3;     }     nYear =atoi(argv[ 1]);     nMonth=atoi(argv[ 2]);     nDay  =atoi(argv[ 3]);     nHour =atoi(argv[ 4]);     nMin  =atoi(argv[ 5]);     nSec  =atoi(argv[ 6]);     lDays =atoi(argv[ 7]);     nHours=atoi(argv[ 8]);     nMins =atoi(argv[ 9]);     nSecs =atoi(argv[10]);     N     =atoi(argv[11]);     if (N<=0) {         printf("Usage:%s sYYYY sMM sDD shh smm sss pDD phh pmm pss n {SQL|YYYY|YY}\n",argv[0]);         return 4;     }     t=COleDateTime( nYear, nMonth, nDay, nHour, nMin, nSec);     ts=COleDateTimeSpan( lDays, nHours, nMins, nSecs );     for (i=1;i<=N;i++) {         s=t.Format(fmt);         printf("%08d %s\n",i,s);         t=t+ts;     }     return 0; }

user: user-0
content: 引用 1 楼 paschen 的回复:返回的是从1970年1月1日的秒数  另外需要考虑一个问题，如果返回很早前到现在的秒数，在32位时（__time32_t）是否会溢出  是返回从1970年1月1日的秒计数，所以上述代码得到的应该是一天的秒计数为3600 * 24 = 86400， 请问为什么不是？

user: user-0
content: 引用 2 楼 zhao4zhong1 的回复:FILETIME The FILETIME structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601.   typedef struct _FILETIME { // ft      DWORD dwLowDateTime;      DWORD dwHighDateTime;  } FILETIME;    Members dwLowDateTime  Specifies the low-order 32 bits of the file time.  dwHighDateTime  Specifies the high-order 32 bits of the file time.  Remarks It is not recommended that you add and subtract values from the FILETIME structure to obtain relative times. Instead, you should   Copy the resulting FILETIME structure to a LARGE_INTEGER structure.  Use normal 64-bit arithmetic on the LARGE_INTEGER value.  QuickInfo   Windows NT: Requires version 3.1 or later.   Windows: Requires Windows 95 or later.   Windows CE: Requires version 1.0 or later.   Header: Declared in winbase.h.  See Also Time Overview, Time Structures, CompareFileTime, GetFileTime, LARGE_INTEGER      Time Functions The following functions are used with time.        CompareFileTime   DosDateTimeToFileTime   FileTimeToDosDateTime   FileTimeToLocalFileTime   FileTimeToSystemTime   GetFileTime   GetLocalTime   GetSystemTime   GetSystemTimeAdjustment   GetSystemTimeAsFileTime   GetTickCount   GetTimeZoneInformation   LocalFileTimeToFileTime   SetFileTime   SetLocalTime   SetSystemTime   SetSystemTimeAdjustment   SetTimeZoneInformation   SystemTimeToFileTime   SystemTimeToTzSpecificLocalTime  老师你想说明啥？

user: user-2
content: 返回的是从1970年1月1日的秒数  另外需要考虑一个问题，如果返回很早前到现在的秒数，在32位时（__time32_t）是否会溢出