Delphi中GetSystemTime这个API的参数

Delphi中GetSystemTime这个API的参数,第1张

先贴个帮助的说明给你

Syntax

VOID GetSystemTime(LPSYSTEMTIME lpst)

Limitations

This function depends on the time zone and eturns the current time as Greenwich mean time (GMT) Requires that an earlier call to SetTimeZoneInformation has been made to get the local time zone 

这个函数依赖于时区 并且返回格林尼治的时间(GMT),使用这个函数应当先调用SetTimeZoneInformation 来设定时区。

LPSYSTEMTIME是个结构

_SYSTEMTIME = record

wYear: Word;

wMonth: Word;

wDayOfWeek: Word;

wDay: Word;

wHour: Word;

wMinute: Word;

wSecond: Word;

wMilliseconds: Word;

end;

GetSystemTime 返回的是Coordinated Universal Time,即协调世界时,又称世界统一时间,世界标准时间,国际协调时间,简称UTC。

中国时区是UTC+8,所以用GetSystemTime获得的小时值要加上8才是本地的时间。

你可以用GetLocalTime函数,它可以直接得到本地时间,使用方法和GetSystemTime函数相同。

增加一个月不止是三十天,有的是29,有的是30,有的是31,从才开学学做程序最好就要严谨用下面的struct tm 这个结构体。先将time_t转换为这个结构体,再将这个结构体的月份加1,如果这个结构体的月份为12就将年份加1,月份置1就可以了

time_t t1;

time_t rawtime;

struct tm target_time;

time ( &rawtime );

target_time = localtime ( &rawtime ); // 其它参数

target_time->tm_year = 2013 - 1900;

target_time->tm_mon = 8 - 1; // 月 - 1

target_time->tm_mday = 20 ; // 日

target_time->tm_hour = 0 ; // 时

target_time->tm_min = 0 ; // 分

target_time->tm_sec = 0 ; // 秒

t1 = mktime (target_time);

以上就是关于Delphi中GetSystemTime这个API的参数全部的内容,包括:Delphi中GetSystemTime这个API的参数、时间的API函数、C++时间显示(自动增加系统时间问题)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/9454733.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-28
下一篇 2023-04-28

发表评论

登录后才能评论

评论列表(0条)

保存