windows 使用GetLocalTime()和GetSystemTime()所獲得的時間不同

來源:互聯網
上載者:User
#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);

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.