time

来源:互联网 发布:如何更改本机端口号 编辑:程序博客网 时间:2024/05/07 18:05

  time_t now = time(NULL);      struct tm *tm;      //struct tm *localtime(const time_t *timep);      tm = localtime(&now);      char buffer[128];#if 0      struct tm      {int tm_sec;/* seconds */int tm_min;/* minutes */int tm_hour;/* hours */int tm_mday;/* day of the month */int tm_mon;/* month */int tm_year;/* year */int tm_wday;/* day of the week */int tm_yday;/* day in the year */int tm_isdst;/* daylight saving time */      };#endif      memset(buffer,0, sizeof(buffer));      //int snprintf(char *str, size_t size, const char *format,...);      snprintf(buffer, sizeof(buffer) - 1, "Current time: %04d-%02d-%02d                    %02d:%02d:%02d\n", tm->tm_year + 1900, tm->tm_mon, tm->tm_mday, tm->tm_hour,                      tm->tm_min, tm->tm_sec);

 get local time promming



原创粉丝点击