linux 获取当前日期与时间
linux 获取当前日期与时间
/* ************************************************************************
* Filename: main.c
* Description:
* Version: 1.0
* Created: 2012年06月19日 10时34分55秒
* Revision: none
* Compiler: gcc
* Author: YOUR NAME (),
* Company:
* ************************************************************************/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int main(int argc, char *argv[])
{
struct timeval tv;
char mytime[20] = "";
gettimeofday(&tv,NULL);
strftime(mytime,sizeof(mytime),"%Y-%m-%d %T",localtime(&tv.tv_sec));
printf("Time:%s\n",mytime);
return 0;
}
转载于//www.cnblogs.com/hnrainll/archive/2012/06/19/2554473.html
还没有评论,来说两句吧...