php - 在php中显示目录中所有文件的修改日期和时间
问题描述
我正在编写如下所示的 php 代码,我想在其中显示目录(outgoing_folder)中所有文件的修改日期和时间。
$destination = 'outgoing_folder';
$mp3_files = preg_grep('/^([^.])/', scandir($destination)); /* Line#Z */
print_r($mp3_files); /* Line#X */
Line#X打印以下内容:
Array ([2] => 36017P.mp3 [3] => 36031P.mp3 [4] => hello.mp3)
我 在Line#A和Line#B处使用了Line#Z ,以便显示目录中所有文件的修改日期和时间。
<?php foreach ($mp3_files as $file ) : ?> /* Line #A */
<tr>
<td style="width:8%; text-align:center;"> <?php echo basename($file, ".mp3"); ?></td>
<td style="width:8%; text-align:center;"><?php echo date("F d Y",filemtime("$file")); ?></td> /* Line #B */
</tr>
<?php
endforeach;
?>
Line#B显示以下 o/p(不是文件的修改日期和时间):
Date
December 31 1969
December 31 1969
December 31 1969
问题陈述:
我想知道我需要在Line#B的 php 代码中进行哪些更改,以便能够检索目录中所有文件的修改日期和时间。
解决方案
推荐阅读
- python - 如何在 wxPython 向导中单独修改面板?
- amazon-ec2 - 使用私钥在 AWS EC2 实例上提供 SSH 访问
- command-line - 命令行; 删除以特定字符开头的文件夹中的静态文件
- server - GraphQL Clojure:获取 GQL 查询字段
- java - 在两个主要类之间传递字符串变量,将其传递给字符串数组
- javascript - 用嵌套数据续集 findAll 限制
- python - 将 pandas shift() 应用于时间索引时间序列时出现问题
- vega - 如何使用 Vega 加载特定的 Topojson
- javascript - JQuery - 如何更改不同切换按钮的颜色?
- c++ - c++ 是否可以从实例访问别名(使用)