// test.cpp : 定义控制台应用程序的入口点。
//
#pragma warning( disable : 4996 )
#include "stdafx.h"
#include "time.h"
#include "windows.h"
#include <iostream>
using namespace std;
void 取系统时间()
{
time_t timer; //time_t实际是int64
struct tm t; //时钟的结构体
time(&timer); //取当前时间(1970年开始的秒数)
localtime_s(&t, &timer); //把int转为时间结构体
std::cout << "年:" << t.tm_year + 1900 << endl;
cout << "月:" << t.tm_mon + 1 << endl;
cout << "日 : " << t.tm_mday << endl;//星期是从星期日开始,星期日是0
cout << "周:" << t.tm_wday << endl;
cout << "一年之中:" << t.tm_yday << endl;
cout << "时 : " << t.tm_hour << endl;
cout << "分 : " << t.tm_min << endl;
cout << "秒 : " << t.tm_sec << endl;
cout << "夏令时 : " << t.tm_isdst << endl;
}
int main()
{
取系统时间();
getchar();
return 0;
}