C语言获取当地时间
#include <time.h> #include <stdio.h> int main() { long logTime; //定义时间类型变量 struct tm *timeinfo; //时间结构的指针 time(&logTime); //获取时间(以秒计,从1970年1月1日起算,存于logTime时间变量) timeinfo=localtime(&logTime); //转为当地时间,tm 时间结构 printf("%s\n",asctime(timeinfo)); }