gpt4 book ai didi

c - C 中的 localtime() 和 gmtime() 有什么区别?

转载 作者:太空狗 更新时间:2023-10-29 17:06:51 26 4
gpt4 key购买 nike

我是 C 编程的新手。谁能告诉我 C 中 localtime() 和 gmtime() 之间的区别是什么?

提前致谢!

最佳答案

来自“本地时间”:

   The  gmtime()  function converts the calendar time timep to broken-down
time representation, expressed in Coordinated Universal Time (UTC). It
may return NULL when the year does not fit into an integer. The return
value points to a statically allocated struct which might be overwrit‐
ten by subsequent calls to any of the date and time functions. The
gmtime_r() function does the same, but stores the data in a user-sup‐
plied struct.

The localtime() function converts the calendar time timep to broken-
time representation, expressed relative to the user’s specified time‐
zone. The function acts as if it called tzset(3) and sets the external
variables tzname with information about the current timezone, timezone
with the difference between Coordinated Universal Time (UTC) and local
standard time in seconds, and daylight to a non-zero value if daylight
savings time rules apply during some part of the year. The return
value points to a statically allocated struct which might be overwrit‐
ten by subsequent calls to any of the date and time functions. The
localtime_r() function does the same, but stores the data in a user-
supplied struct. It need not set tzname, timezone, and daylight.

关于c - C 中的 localtime() 和 gmtime() 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5409025/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com