1CURLINFO_FILETIME(3) curl_easy_getinfo options CURLINFO_FILETIME(3)
2
3
4
6 CURLINFO_FILETIME - get the remote time of the retrieved document
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_FILETIME, long *timep);
12
14 Pass a pointer to a long to receive the remote time of the retrieved
15 document in number of seconds since January 1 1970 in the GMT/UTC time
16 zone. If you get -1, it can be because of many reasons (it might be un‐
17 known, the server might hide it or the server does not support the com‐
18 mand that tells document time etc) and the time of the document is un‐
19 known.
20
21 You must tell libcurl to collect this information before the transfer
22 is made, by using the CURLOPT_FILETIME(3) option to curl_easy_setopt(3)
23 or you will unconditionally get a -1 back.
24
25 Consider using CURLINFO_FILETIME_T(3) to be able to extract dates be‐
26 yond the year 2038 on systems using 32 bit longs.
27
29 HTTP(S), FTP(S), SFTP
30
32 curl = curl_easy_init();
33 if(curl) {
34 curl_easy_setopt(curl, CURLOPT_URL, url);
35 /* Ask for filetime */
36 curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
37 res = curl_easy_perform(curl);
38 if(CURLE_OK == res) {
39 res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
40 if((CURLE_OK == res) && (filetime >= 0)) {
41 time_t file_time = (time_t)filetime;
42 printf("filetime %s: %s", filename, ctime(&file_time));
43 }
44 }
45 /* always cleanup */
46 curl_easy_cleanup(curl);
47 }
48
50 Added in 7.5
51
53 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
54 if not.
55
57 curl_easy_getinfo(3), curl_easy_setopt(3),
58
59
60
61libcurl 8.0.1 January 02, 2023 CURLINFO_FILETIME(3)