获取当前时间

  1. static void get_local_time(char *pc_str)
  2. {
  3.     time_t now;
  4.     struct tm *timenow;
  5.     assert(pc_str != NULL);
  6. /*
    1. time_t t;
    2.   srand((unsigned)time(&t));    //初始化随机种子, 否则随机数不随机
  7. */
  8.     time(&now);
  9.     timenow = localtime(&now);
  10.     sprintf(pc_str, "%04d-%02d-%02dT%02d:%02d:%02d", timenow->tm_year+1900, timenow->tm_mon+1, timenow->tm_mday,
  11.                     timenow->tm_hour, timenow->tm_min, timenow->tm_sec);
  12. }

 

posted @ 2016-02-29 11:59  强者最帅  阅读(125)  评论(0)    收藏  举报