获取远程文件的最后修改日期 [英] Get the last modified date of a remote file

查看:32
本文介绍了获取远程文件的最后修改日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 curl 获取远程文件的最后修改日期.有谁知道这是怎么做到的吗?

I would like to get the last modified date of a remote file by means of curl. Does anyone know how to do that?

推荐答案

来自 php 的文章:>

<?php
// outputs e.g.  somefile.txt was last modified: December 29 2002 22:16:23.

$filename = 'somefile.txt';
if (file_exists($filename)) {
    echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));
}
?>

filemtime() 是这里的关键.但我不确定您是否可以获得 远程 文件的最后修改日期,因为服务器应该将其发送给您...也许在 HTTP 标头中?

filemtime() is the key here. But I'm not sure if you can get the last modified date of a remote file, since the server should send it to you... Maybe in the HTTP headers?

这篇关于获取远程文件的最后修改日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆