5

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?

johnnycrash
  • 5,184
  • 5
  • 34
  • 58
  • 1
    I'd say it's pretty irrelevant. Either way, the same amount of seconds have passed; the result is going to be calculated in the same time system the data is stored in. – Paul Manta Jun 07 '11 at 22:03
  • If I don't know the units of st_mtime, how can I use it? If it was local time with DST, wouldn't it be +- 1 hr +- Z hr as compared to GMT? – johnnycrash Jun 07 '11 at 22:11

1 Answers1

9

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.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • Doesn't really affect the answer, but just as an FYI, UTC and GMT are in fact different and GMT is certainly not deprecated. They differ by one hour during daylight savings time. Caused my team MAJOR headaches in a UK data center once upon a time. – John Wu Jul 03 '14 at 14:43
  • @JohnWu: I just noticed that somebody else edited my answer to add incorrect information, which you responded to. Apologies; I have removed the incorrect information and added a link to further explanation. – Greg Hewgill Jul 03 '14 at 17:36