得到操作系统精确时间的Linux命令
至少要到毫米秒级的,
请写清楚格式.
我是菜鸟,请指教.
------解决方案--------------------void
get_times (char *timestamp)
{
struct timeb strTime;
struct tm strLocaltime;
ftime (&strTime);
localtime_r (&strTime.time, &strLocaltime);
sprintf (timestamp, "%04d/%02d/%02d %02d:%02d:%02d:%03d ",
strLocaltime.tm_year + 1900, strLocaltime.tm_mon + 1,
strLocaltime.tm_mday, strLocaltime.tm_hour,
strLocaltime.tm_min, strLocaltime.tm_sec, strTime.millitm);
}
------解决方案--------------------date +%H:%M:%S.%N
------解决方案--------------------time