- #include <iostream.h>
- //#include <winbase.h>
- #include <windows.h>
- //#pragma comment(lib,"kernel32.lib")
- //using namespace std;
- void main()
- {
- SYSTEMTIME systime;
- GetLocalTime(&systime);//本地时间
- cout<<"今天是:";
- cout<<systime.wYear<<"年"<<systime.wMonth<<"月"<<systime.wDay<<"日"<<endl;
- cout<<"现在时间是:";
- cout<<systime.wHour<<":"<<systime.wMinute<<":"<<systime.wSecond<<":"<<systime.wMilliseconds<<endl;
- cout<<"星期"<<systime.wDayOfWeek<<endl;
- cout<<endl;
- GetSystemTime(&systime);//系统时间
- cout<<"现在时间是:";
- cout<<systime.wHour<<":"<<systime.wMinute<<":"<<systime.wSecond<<":"<<systime.wMilliseconds<<endl;
- cout<<endl;
- }
- GetSystemTime:所返回的是UTC.
- 协调世界时(Coordinated Universal Time,简写作UTC,之前也被拼做Universal Time Coordinated,有时是Universal Coordinated Time)是由国际无线电咨询委员会定义和建议采用的,并由国际时间局(BIH)负责保持的以国际单位制(SI)秒为单位的时间标度。对与无线电规则相关的大部分实际应用而言,协调世界时(UTC)与本初子午线(经度零度)上的平均太阳时等效。该时间过去以格林威治平均时(GMT)表示。
- 协调世界时使用24小时制的时钟表示,但也可以被转换为12小时制的时钟(AM和PM)。UTC用于飞行和航海,它有时也被称作祖鲁。UTC使用阳历
- --------------------------------
- GetLocalTime:返回的是本地时间,我建议一般用这个时间来作为你使用的时间
- void getsystemtime(
- lpsystemtime lpsystemtime // system time
- );
- void getlocaltime(
- lpsystemtime lpsystemtime // system time
- );
- typedef struct _systemtime {
- word wyear;
- word wmonth;
- word wdayofweek;
- word wday;
- word whour;
- word wminute;
- word wsecond;
- word wmilliseconds;
- } systemtime, *psystemtime;
- SYSTEMTIME systm;
- GetSystemTime(&systm);
windows 使用GetLocalTime()和GetSystemTime()所获得的时间不同
最新推荐文章于 2021-05-25 08:50:37 发布