Get the last modified date of a remote file

前端 未结 8 2069
难免孤独
难免孤独 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:12

    would something like this work, from web developer forum

    <? $last_modified = filemtime("content.php"); print("Last Updated - ");
    print(date("m/d/y", $last_modified)); ?
    
    // OR
    
    $last_modified = filemtime(__FILE__); 
    

    the link provides some useful insite on you can use them

    0 讨论(0)
  • 2020-11-29 03:14

    Had to solve similiar issue, but for me download once a day was enough so I compared just the modify day of the local (downloaded) cache file. The remote file had no Last-Modified header.

    $xml = 'test.xml';
    if (is_file($xml) || date('d', filemtime($xml)) != date('d')) {
        $xml = file_get_contents(REMOTE_URL);
    }
    
    0 讨论(0)
提交回复
热议问题