示例代码:
/*
author : kj
time : 2013-12-06 21:36
instruction:
get the num of the current seconds
*/
int get_current_time_second(void)
{
struct tm *tmnow;
struct timeval tv;
gettimeofday(&tv,NULL);
tmnow = localtime(&tv.tv_sec);
return tv.tv_sec;
}
int get_current_time_to_jms(char *buf)
{
struct tm *tmnow;
struct timeval tv;
gettimeofday(&tv,NULL);
tmnow = localtime(&tv.tv_sec);
sprintf(buf,"%04d-%02d-%02d %02d:%02d:%02d",\
tmnow->tm_year+1900, tmnow->tm_mon+1, tmnow->tm_mday,tmnow->tm_hour,\
tmnow->tm_m