当前位置: 技术问答>linux和unix
得到操作系统精确时间的Linux命令
来源: 互联网 发布时间:2016-02-02
本文导语: 至少要到毫米秒级的, 请写清楚格式. 我是菜鸟,请指教. | date +%H:%M:%S.%N | void get_times (char *timestamp) { struct timeb strTime; struct tm strLocaltime; ftime (&strTime); localtime_r (&strTime...
至少要到毫米秒级的,
请写清楚格式.
我是菜鸟,请指教.
请写清楚格式.
我是菜鸟,请指教.
|
date +%H:%M:%S.%N
|
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);
}
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);
}
|
time