您的位置:首页 > 其它

GetLocalTime和GetSystemTime

2010-02-09 16:44 405 查看
(1) GetLocalTime和GetSystemtime 的区别:

使用GetLocalTime()和GetSystemTime()所获得的时间不同

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;

/*

1.GetSystemTime:返回参数:UTC.
协调世界时间(Coordinated Universal Time),简写作UTC。之前也被称为:Universal Time
Coordinated,有时是Universal Coordinated Time)是由国际无线电咨询委员会定义和
建议采用的,并由国际时间局(BIH)负责保持的以国际单位制(SI)秒为单位的时间标
度。对与无线电规则相关的大部分实际应用而言,协调世界时(UTC)与本初子午线(经
度零度)上的平均太阳时等效。该时间过去以格林威治平均时(GMT)表示。协调世界时
使用24小时制的时钟表示,但也可以被转换为12小时制的时钟(AM和PM)。UTC用于飞行
和航海,它有时也被称作祖鲁。UTC使用阳历。
2.GetLocalTime:返回的是本地时间,我建议一般用这个时间来作为你使用的时间

*/

//代码如下:0.1

#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;
}

部分内容来源于网络,已注明。

red 2010/02/09
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: