johnnycrash
johnnycrash

Reputation: 5344

Are struct stat times GMT?

One of the fields in struct stat is st_mtime. I assume that is seconds since jan 1, 1970. Is that GMT or local time?

Upvotes: 5

Views: 3928

Answers (1)

Greg Hewgill
Greg Hewgill

Reputation: 993095

The time_t type represents the number of seconds that have passed since 1 January 1970 00:00 UTC (that moment in time is called the "epoch" and happened at the same moment everywhere around the world). You can consider "UTC" to mean the same thing as "GMT" (see Leap Second for detail about the very small differences).

Be aware that instead of adding or subtracting values from the time_t type, you should always use the localtime() and mktime() functions to convert to and from a local time zone representation.

Upvotes: 9

Related Questions