Get the last modified date of a remote file

前端 未结 8 2117
难免孤独
难免孤独 2020-11-29 02:45

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

8条回答
  •  自闭症患者
    2020-11-29 03:07

    By editing h4kuna's answer I created this:

    $fileURL='http://www.yahoo.com';
    $headers = get_headers($fileURL, 1);
    $date = "Error";
    //echo "
    "; print_r($headers); echo "
    "; if ( $headers && (strpos($headers[0],'200') !== FALSE) ) { $time=strtotime($headers['Last-Modified']); $date=date("d-m-Y H:i:s", $time); } echo 'file: '.$fileURL.' (Last-Modified: '.$date.')
    ';

提交回复
热议问题