【问题标题】:php static countdown with filemtime [closed]带有filemtime的php静态倒计时[关闭]
【发布时间】:2012-01-30 07:31:58
【问题描述】:

文件每 60 分钟更新一次。我想通过比较文件时间和时间来为下一次更新倒计时。

我在处理时间问题上放了个屁

【问题讨论】:

    标签: php time static countdown filemtime


    【解决方案1】:

    filemtime()time() 都返回 Unix Timestamp:自 1970 年 1 月 1 日 00:00:00 GMT 以来的秒数。因此,只需将filemtime() 的值减去time() 的值,即可得到自上次修改文件以来经过的秒数。

    $modifiedTime = filemtime("somefile.txt");
    $now = time();
    $timeSinceModified = $now - $modifiedTime; //Time since modified in seconds.
    

    如果您想要另一个时间单位的值,只需乘以或除以。

    例如,$timeSinceModified / 60 会给您以分钟为单位的时间。

    【讨论】:

      猜你喜欢
      • 2013-03-15
      • 2013-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-20
      • 1970-01-01
      相关资源
      最近更新 更多