【问题标题】:How to remove the difference in time with Epoch time?如何消除与 Epoch 时间的时间差异?
【发布时间】:2012-09-04 06:03:37
【问题描述】:

我试图从它的 inode 找出文件的创建时间。我已经使用 gmtime() 转换为正常时间。但与 ls -l 命令显示的时间相差 6 小时 30 分钟。

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

【问题讨论】:

    标签: c time epoch


    【解决方案1】:

    来自 ma​​n 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.  
    

    【讨论】:

      【解决方案2】:

      我假设您使用的是 linux。在 unix 中不存储创建时间;你只有最后一次访问时间(atime)、最后一次修改内容的时间(mtime)和最后一次修改inode的时间(ctime)。

      所以检查你从 inode 中检索的内容并与 ls -l 进行比较

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-07-07
        • 2015-04-10
        • 1970-01-01
        • 1970-01-01
        • 2010-12-20
        相关资源
        最近更新 更多