2011-03-23 56 views
4

我是C編程的新手。誰能告訴我C中localtime()和gmtime()之間有什麼區別?C中localtime()和gmtime()之間的區別是什麼?

謝謝!

+3

你明白一個時區是什麼? – 2011-03-23 17:15:20

+0

當我不得不面對全球時代時,我喜歡[時間和日期* dot * com](http://timeanddate.com/)。 – pmg 2011-03-23 18:12:46

回答

5

從「男人本地時間」:

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. 
+0

感謝您的回答=) – alwinlin 2011-03-23 22:03:57

6

gmtime的是協調世界時(UTC),而本地時間是在你的時區

相關問題