CURLINFO_FILETIME.md (1970B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLINFO_FILETIME 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_FILETIME (3) 9 - curl_easy_getinfo (3) 10 - curl_easy_setopt (3) 11 Protocol: 12 - HTTP 13 - FTP 14 - SFTP 15 Added-in: 7.5 16 --- 17 18 # NAME 19 20 CURLINFO_FILETIME - get the remote time of the retrieved document 21 22 # SYNOPSIS 23 24 ~~~c 25 #include <curl/curl.h> 26 27 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_FILETIME, long *timep); 28 ~~~ 29 30 # DESCRIPTION 31 32 Pass a pointer to a long to receive the remote time of the retrieved document 33 in number of seconds since January 1 1970 in the GMT/UTC time zone. If you get 34 -1, it can be because of many reasons (it might be unknown, the server might 35 hide it or the server does not support the command that tells document time 36 etc) and the time of the document is unknown. 37 38 You must ask libcurl to collect this information before the transfer is made, 39 by using the CURLOPT_FILETIME(3) option or you unconditionally get a -1 back. 40 41 Consider CURLINFO_FILETIME_T(3) instead to be able to extract dates beyond the 42 year 2038 on systems using 32-bit longs (Windows). 43 44 # %PROTOCOLS% 45 46 # EXAMPLE 47 48 ~~~c 49 int main(void) 50 { 51 CURL *curl = curl_easy_init(); 52 if(curl) { 53 CURLcode res; 54 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 55 /* Ask for filetime */ 56 curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); 57 res = curl_easy_perform(curl); 58 if(CURLE_OK == res) { 59 long filetime = 0; 60 res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime); 61 if((CURLE_OK == res) && (filetime >= 0)) { 62 time_t file_time = (time_t)filetime; 63 printf("filetime: %s", ctime(&file_time)); 64 } 65 } 66 /* always cleanup */ 67 curl_easy_cleanup(curl); 68 } 69 } 70 ~~~ 71 72 # %AVAILABILITY% 73 74 # RETURN VALUE 75 76 curl_easy_getinfo(3) returns a CURLcode indicating success or error. 77 78 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 79 libcurl-errors(3).