在windows下和在linux下获取当前时间
static void get_current_time(char *str)
{#ifdef _WIN32
SYSTEMTIME st;
GetLocalTime(&st);//GetSystemTime
sprintf(str,"%04d-%02d-%02d %02d:%02d:%02d.%03d",
st.wYear,
st.wMonth,
st.wDay,
st.wHour,
st.wMinute,
st.wSecond,
st.wMilliseconds);
#else
struct tm *now;
time_t second;
time(&second);
now=localtime(&second);
sprintf(str,"%04d-%02d-%02d %02d:%02d:%02d",
now->tm_year+1900,
now->tm_mon+1,
now->tm_mday,
now->tm_hour,
now->tm_min,
now->tm_sec);
#endif
}