如何消除Epoch时间的差异?

时间:2012-09-11 10:15:49

标签: c time epoch

我试图从其inode中找出文件的创建时间。我用gmtime()转换成正常时间。但是与ls -l命令显示的时间差异为6小时30分钟。

为什么会这样?如何消除这种差异?

2 个答案:

答案 0 :(得分:2)

来自 man gmtime

   The  gmtime()  function  converts  the  calendar  time timep to broken-down time representation, expressed in Coordinated Universal Time
   (UTC).

   ...............

   The localtime() function converts the calendar time timep to broken-time representation, expressed  relative  to  the  user's  specified
   timezone.  

答案 1 :(得分:0)

我想你正在使用linux。在unix中,创建时间不存储;你只有最后一次访问的时间(atime),内容的最后修改时间(mtime),以及inode(ctime)的最后修改时间。

因此,请检查您从inode检索的内容并与ls -l <​​/ p>进行比较