#include <time.h>
//* 方法一
time_t tt = time(NULL);//這句返回的只是一個時間cuo
tm* t= localtime(&tt);
printf("%d-%02d-%02d %02d:%02d:%02d\n",
t->tm_year + 1900,
t->tm_mon + 1,
t->tm_mday,
t->tm_hour,
t->tm_min,
t->tm_sec);
//* 方法二
SYSTEMTIME st = {0};
GetLocalTime(&st);
printf("%d-%02d-%02d %02d:%02d:%02d\n",
st.wYear,
st.wMonth,
st.wDay,
st.wHour,
st.wMinute,
st.wSecond);
下面幾個,是網上找的:轉載地址: http://apps.hi.baidu.com/share/detail/17815869
注意:GetLocalTime()與GetSystemTime()是有區別的
//* 方法一
time_t tt = time(NULL);//這句返回的只是一個時間cuo
tm* t= localtime(&tt);
printf("%d-%02d-%02d %02d:%02d:%02d\n",
t->tm_year + 1900,
t->tm_mon + 1,
t->tm_mday,
t->tm_hour,
t->tm_min,
t->tm_sec);
//* 方法二
SYSTEMTIME st = {0};
GetLocalTime(&st);
printf("%d-%02d-%02d %02d:%02d:%02d\n",
st.wYear,
st.wMonth,
st.wDay,
st.wHour,
st.wMinute,
st.wSecond);
下面幾個,是網上找的:轉載地址: http://apps.hi.baidu.com/share/detail/17815869
注意:GetLocalTime()與GetSystemTime()是有區別的