#include
#include
using namespace std;
int main()
{
int day,month,year,wday;
time_t t;
struct tm * timeinfo;
time(&t);
timeinfo = localtime(&t);
day = timeinfo->tm_mday;
month = timeinfo->tm_mon + 1;
year = timeinfo->tm_year + 1900;
wday = timeinfo->tm_wday;
cout<return 0;
}
输出年月日和星期几。
time_t t=time(0); //当前时间差(秒)
localtime(&t) --- 将time(0)转换成日历,已经进行过时区转换,返回指向 tm结构体指针,tm存储时间的各个量, t != NULL
{tm_year, tm_mon, tm_mday, tm_hour,
tm_min, tm_sec}
#include
#include
#include
using namespace std;
int main()
{
while(1)
{
system("cls");
SYSTEMTIME sysTime;
ZeroMemory(&sysTime, sizeof(sysTime));
GetLocalTime(&sysTime);
cout << "Current time: " << sysTime.wYear << "/" << sysTime.wMonth << "/" <cout <<" "< Sleep(1000);
}
return 0;
}
可以看看这个程序 满不满足你的要求?