// get the run time (seconds)
struct sysinfo s_info;
long uptime = 0;
if(0==sysinfo(&s_info))
{
uptime = s_info.uptime;
}
// get current time
time_t timep;
struct tm *p;
time( &timep );
// get the up time
timep -= uptime;
// change to the local time
p = localtime( &timep );
char ctime[256] = {0x00};
memset( ctime, 0x00, sizeof(ctime) );
strftime( ctime, sizeof(ctime),"%Y-%m-%d %H:%M:%S", p );
printf( "你的系统启动时间是:%s/n", ctime );