Linux下获取系统时间
void get_sys_time(char buf[]){time_t now;struct tm *timenow;time(&now);timenow=localtime(&now);memset(buf,0,sizeof(buf));sprintf(buf,"%d-%d-%d %d:%d:%d",timenow->tm_year+1900, timenow->tm_mon+1, timen
·
void get_sys_time(char buf[])
{
time_t now;
struct tm *timenow;
time(&now);
timenow=localtime(&now);
memset(buf,0,sizeof(buf));
sprintf(buf,"%d-%d-%d %d:%d:%d",timenow->tm_year+1900, timenow->tm_mon+1, timenow->tm_mday,timenow->tm_hour, timenow->tm_min, timenow->tm_sec);
}
说明:timenow中的内容是不断更新的,与系统时间一致。更多推荐
已为社区贡献5条内容
所有评论(0)