标签:io ar for sp on amp 时间 bs as
time_t到struct tm的转换:
#include <time.h> struct tm *localtime(const time_t *timep);
#include <time.h> time_t mktime(struct tm *tm);
示例程序;
#include <stdio.h> #include <stdlib.h> #include <time.h> int main (int argc, char **argv) { int i; time_t timer[4]; struct tm tm, *p; tm.tm_year = 2015; tm.tm_mon = 2; tm.tm_mday = 23; tm.tm_hour = 8; tm.tm_min = 22; tm.tm_sec = 0; for(i = 0; i < 4; i++){ timer[i] = mktime(&tm); printf ("timer[%d] = %ld\n", i, timer[i]); p = localtime(&timer[i]); printf("%d-%d-%d-%d-%d-%d\n", p->tm_year, p->tm_mon, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec); } return 0; } /* ----- End of main() ----- */
标签:io ar for sp on amp 时间 bs as
原文地址:http://blog.csdn.net/fulinus/article/details/40083295