【发布时间】:2017-06-29 01:23:02
【问题描述】:
我已经阅读http://php.net/manual/en/function.touch.php 了解如何设置文件修改日期,但我的日期格式是:
$date = "5/11/2017 08:32 PM EST";
如何触摸带有该日期的文件?
$filename = "text.txt";
if (!touch($filename, $date)) {
echo 'Whoops, something went wrong...';
} else {
echo 'Touched file with success';
}
【问题讨论】:
-
strtotime可以将日期字符串转换为 Unix 时间戳 -
touch() 需要第二个参数是 UNIX 时间戳。 secure.php.net/manual/en/function.strtotime.php 这是一种方法,但我建议您使用 DateTime 方法以确保获得最佳结果
-
顺便说一句;您还有其他关于解决方案的问题;最好将它们标记为已解决。它们被认为仍未解决/未解决。