为什么我在1969年12月31日使用php中的filemtime作为我上次修改的文件名?

Rac*_*hel 2 php datetime function

我是php的新手,所以请不要介意我问这个问题,但我真的很困惑,为什么filemtime(filename.txt)给我1969年12月31日作为我上次修改时间?

Pas*_*TIN 8

这可能意味着找不到您的文件:

  • 因为它不存在
  • 或者因为它不在current目录中
  • 或者因为你没引用它的名字 - 你没有^^

1970年1月1日是时间"零"的日期; 并在出现问题时filemtime返回false...

因此,1969年12月31日的零日期/时间......根据您所在的地区,我想; 我自己,用这个代码:

$filemtime = filemtime(filename.txt);
$formated = date('Y-m-d H:i:s', $filemtime);
var_dump($filemtime, $formated);
Run Code Online (Sandbox Code Playgroud)

得到这个输出:

boolean false
string '1970-01-01 01:00:00' (length=19)
Run Code Online (Sandbox Code Playgroud)

假的,因为该文件犯规"存在,并且1970-01-0101:00因为我的语言环境(我在法国,在UTC + 1小时)


请注意,我还收到了一些通知和警告:

  • Notice: Use of undefined constant filename - assumed 'filename'
  • Notice: Use of undefined constant txt - assumed 'txt'
  • Warning: filemtime() [function.filemtime]: stat failed for filenametxt

你有这些吗?
如果否:是error_reporting和/或display_errors启用?