char* genetimechar() {
time_t t;
char *s;
struct tm *p;
s = (char*) malloc(30 * sizeof(char));
time(&t);
p = gmtime(&t);
t = mktime(p);
sprintf(s, "%ld", t);
return s;
}
time_t t;
char *s;
struct tm *p;
s = (char*) malloc(30 * sizeof(char));
time(&t);
p = gmtime(&t);
t = mktime(p);
sprintf(s, "%ld", t);
return s;
}

本文介绍了一个使用C语言实现的时间戳生成函数。该函数通过获取当前时间并转换为格林威治标准时间,最终将时间格式化为字符串形式的时间戳。

被折叠的 条评论
为什么被折叠?



