本文共 629 字,大约阅读时间需要 2 分钟。
自己的微妙代码:
struct timezone tz; struct timeval tv; /*获取时间*/ gettimeofday(&tv, &tz); printf("now1: %ld %ld\n", tv.tv_sec, tv.tv_usec); write(uart_fd, send_buf, BUF_MAX); gettimeofday(&tv, &tz); printf("now2: %ld %ld\n", tv.tv_sec, tv.tv_usec);网上能用代码:
/*time_t now; //实例化time_t结构
struct tm *timenow; //实例化tm结构指针 time(&now); //time函数读取现在的时间(国际标准时间非北京时间),然后传值给now timenow = localtime(&now); //localtime函数把从time取得的时间now换算成你电脑中的时间(就是你设置的地区) printf("Local time is %s\n",asctime(timenow)); */ //getNowTime(nowTime); //printf("nowTime1 is %s.wenkewenkewenke\n", nowTime); //for(i=0;i<14;i++) // printf("%c", nowTime[i]);转载地址:http://eklpi.baihongyu.com/