vxworks获取系统时间编程

#include<time.h> //头文件

unsigned int timeLen;

struct timespec tp;

struct tm timeBuffer;

time_t nowSec;

char datetime[64];

/* prepare the time stamp */

(void)clock_gettime(CLOCK_REALTIME, &tp);

nowSec = tp.tv_sec;

(void)gmtime_r(&nowSec, &timeBuffer);

timeLen = strftime(datetime, 64, "%y%m%d %H:%M:%S", &timeBuffer);

sprintf(datetime + timeLen, ".%3.3ld", tp.tv_nsec / 1000000L);

printf("datetime is :%s,now feed si-e watchdog!\n",datetime);

posted on 2013-12-12 17:16  我的小人生  阅读(2780)  评论(0编辑  收藏  举报