我得到的絕對時間值,如下例所示如何將無符號值轉換爲struct tm?
1413399540000
1411047780000
1411574340000
我怎樣才能將它們轉換爲「結構TM」在C++?
您好勒夫,
這是從GUI用於accesslist中時間範圍的輸入和我嘗試以下,
的typedef無符號長長uint64_t中;
uint64_t mytime;
struct tm *tm;
time_t realtime;
mytime = 1447862580005ULL;
realtime = (time_t) (mytime/1000000);
printf ("The current local time is: %s", ctime(&realtime));
tm = localtime(&realtime);
printf ("The current local time is: %s", asctime(tm));
tm->tm_year +=1900;
tm->tm_mon +=1;
printf("%04d-%02d-%02d %02d:%02d:%02d\n",
tm->tm_year,tm->tm_mon, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
O/P:
The current local time is: Sat Jan 17 10:11:02 1970 The current local time is: Sat Jan 17 10:11:02 1970 1970-01-17 10:11:02
外貌迷惑到me.Not知道如何驗證轉換得到corect值與否。
這些時間戳的單位是什麼?你有什麼嘗試? – 2014-09-24 12:57:49
http://www.cplusplus.com/reference/ctime/gmtime/ – dasblinkenlight 2014-09-24 12:58:17
嗨Joachim,這是一個來自GUI的輸入訪問列表時間範圍,我嘗試了以下, – user2652753 2014-09-24 13:04:32