CURLINFO_FILETIME_T.md (2047B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLINFO_FILETIME_T 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.59.0 16 --- 17 18 # NAME 19 20 CURLINFO_FILETIME_T - 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_T, 28 curl_off_t *timep); 29 ~~~ 30 31 # DESCRIPTION 32 33 Pass a pointer to a curl_off_t to receive the remote time of the retrieved 34 document in number of seconds since January 1 1970 in the GMT/UTC time zone. 35 If you get -1, it can be because of many reasons (it might be unknown, the 36 server might hide it or the server does not support the command that tells 37 document time etc) and the time of the document is unknown. 38 39 You must ask libcurl to collect this information before the transfer is made, 40 by using the CURLOPT_FILETIME(3) option or you unconditionally get a -1 back. 41 42 This option is an alternative to CURLINFO_FILETIME(3) to allow systems with 32 43 bit long variables to extract dates outside of the 32-bit timestamp range. 44 45 # %PROTOCOLS% 46 47 # EXAMPLE 48 49 ~~~c 50 int main(void) 51 { 52 CURL *curl = curl_easy_init(); 53 if(curl) { 54 CURLcode res; 55 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); 56 /* Ask for filetime */ 57 curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); 58 res = curl_easy_perform(curl); 59 if(CURLE_OK == res) { 60 curl_off_t filetime; 61 res = curl_easy_getinfo(curl, CURLINFO_FILETIME_T, &filetime); 62 if((CURLE_OK == res) && (filetime >= 0)) { 63 time_t file_time = (time_t)filetime; 64 printf("filetime: %s", ctime(&file_time)); 65 } 66 } 67 /* always cleanup */ 68 curl_easy_cleanup(curl); 69 } 70 } 71 ~~~ 72 73 # %AVAILABILITY% 74 75 # RETURN VALUE 76 77 curl_easy_getinfo(3) returns a CURLcode indicating success or error. 78 79 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 80 libcurl-errors(3).