Ubuntu获取系统时间

#include <stdio.h> #include <sys/time.h> #include <time.h> int gettimeofday(struct timeval *tv,struct timezone *tz); int main(int argc,char * argv[]) { struct timeval tv; struct tm *gmt,*area; while(1) { gettimeofday(&tv,0); area = localtime(&(tv.tv_sec));//以本地时区显示时间 printf("Local time is: %s %u:%u",asctime(area),tv.tv_sec,tv.tv_usec); //打印文件名和此段程序行数,并显示系统时间和微秒数; //printf("s: %u:%u\n",tv.tv_usec); //gmt = gmtime(&(tv.tv_sec));//以GMT时区显示时间 //printf("GMT is: %s",asctime(gmt)); //  sleep(2);    } return 0; }

相关文章

ubuntu退出redis的示例:指定配置文件方式启动源码redis:roo...
ubuntu中mysql改密码忘了的解决方法:1.在终端中切换到root权...
ubuntu安装mysql失败的解决方法原因:可能是原有的MySQL还有...
使用centos和ubuntu建站的区别有以下几点1.CentOS是Linux发行...
ubuntu图形界面和字符界面切换的方法:可以通过快捷键CTRL+A...
ubuntu中重启mysql失败的解决方法1.首先,在ubuntu命令行中,...