1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_FILETIME 5Section: 3 6Source: libcurl 7See-also: 8 - CURLINFO_FILETIME (3) 9 - curl_easy_getinfo (3) 10--- 11 12# NAME 13 14CURLOPT_FILETIME - get the modification time of the remote resource 15 16# SYNOPSIS 17 18~~~c 19#include <curl/curl.h> 20 21CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FILETIME, long gettime); 22~~~ 23 24# DESCRIPTION 25 26Pass a long. If it is 1, libcurl attempts to get the modification time of the 27remote document in this operation. This requires that the remote server sends 28the time or replies to a time querying command. The curl_easy_getinfo(3) 29function with the CURLINFO_FILETIME(3) argument can be used after a 30transfer to extract the received time (if any). 31 32# DEFAULT 33 340 35 36# PROTOCOLS 37 38HTTP(S), FTP(S), SFTP, FILE, SMB(S) 39 40# EXAMPLE 41 42~~~c 43int main(void) 44{ 45 CURL *curl = curl_easy_init(); 46 if(curl) { 47 CURLcode res; 48 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/path.html"); 49 /* Ask for filetime */ 50 curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); 51 res = curl_easy_perform(curl); 52 if(CURLE_OK == res) { 53 long filetime; 54 res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime); 55 if((CURLE_OK == res) && (filetime >= 0)) { 56 time_t file_time = (time_t)filetime; 57 printf("filetime: %s", ctime(&file_time)); 58 } 59 } 60 /* always cleanup */ 61 curl_easy_cleanup(curl); 62 } 63} 64~~~ 65 66# AVAILABILITY 67 68Always, for SFTP since 7.49.0 69 70# RETURN VALUE 71 72Returns CURLE_OK 73