*[36m開發平台(Platform): (Ex: Win10, Linux, ...)
Linux
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
Gcc
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
NA
問題(Question):
如何回傳epoch時間
傳入(YYYMMDD, ms) ms的格式由 0 ~235959999 回傳epoch時間
找到類似的範列如下:
這是抓系統時間:
* timestamp example */
#include <stdio.h> /* printf */
#include <time.h> /* time_t, time (for timestamp in second) */
#include <sys/timeb.h> /* ftime, timeb (for timestamp in millisecond) */
#include <sys/time.h> /* gettimeofday, timeval (for timestamp in microsecond) */
int main ()
{
/* Example of timestamp in millisecond. */
struct timeb timer_msec;
long long int timestamp_msec; /* timestamp in millisecond. */
if (!ftime(&timer_msec)) {
timestamp_msec = ((long long int) timer_msec.time) * 1000ll +
(long long int) timer_msec.millitm;
}
else {
timestamp_msec = -1;
}
printf("%lld milliseconds since epoch\n", timestamp_msec);
return 0;
}
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
程式碼(Code):(請善用置底文網頁, 記得排版)
補充說明(Supplement):