如何获取 ISO 8601 格式的当前时间?它应该看起来像 2011-11-16T22:06Z
最佳答案
纯 C 解决方案,仅使用标准 C 功能:
#include <stdio.h>
#include <time.h>
int main(void) {
time_t now = time(NULL);
struct tm *now_tm = gmtime(&now);
char iso_8601[] = "YYYY-MM-DDTHH:MMZ";
/* init just to get the right length */
strftime(iso_8601, sizeof iso_8601, "%FT%RZ", now_tm);
puts(iso_8601);
return 0;
}
关于objective-c - Objective C - 如何以 ISO 8601 格式获取当前时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8161615/