*[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):