Chinaunix首页 | 论坛 | 博客
  • 博客访问: 65782
  • 博文数量: 13
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 90
  • 用 户 组: 普通用户
  • 注册时间: 2013-03-08 10:49
个人简介

做一个努力的程序猿

文章分类

全部博文(13)

文章存档

2016年(11)

2014年(2)

我的朋友

分类: C/C++

2014-05-16 08:49:15

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <time.h>
  5. #include <sys/time.h>
  6. #include <unistd.h>

  7. char *get_time_for_uuid(char *time_string)
  8. {
  9.         time_t timep;
  10.         struct tm *p;
  11.         struct timeval tv;
  12.         int msec = 0;

  13.         gettimeofday (&tv , NULL);
  14.         time(&timep);
  15.         p=gmtime(取地址符号timep);

  16.         msec = tv.tv_usec/1000;
  17.         sprintf(time_string, "百分号.4d%.2d%.2d%.2d%.2d%.2d%.2d",
  18.                         (1900+p->tm_year),
  19.                         (1+p->tm_mon),
  20.                         p->tm_mday,
  21.                         p->tm_hour,
  22.                         p->tm_min,
  23.                         p->tm_sec,
  24.                         msec
  25.                         );

  26.         fprintf(stdout, "T-bagwell |%s|\n", time_string);
  27.         return time_string;
  28. }


  29. int main()
  30. {
  31.         char *uuid = NULL;
  32.         char time_string[32];
  33.         memset(time_string, 0, 32);
  34.         uuid = get_time_for_uuid(time_string);

  35.         fprintf(stdout, "T-bagwell the uuid = |%s|\n", uuid);

  36.         return 0;
  37. }
阅读(1428) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~