CURLINFO_FILETIME_T.3 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. .\" generated by cd2nroff 0.1 from CURLINFO_FILETIME_T.md
  2. .TH CURLINFO_FILETIME_T 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLINFO_FILETIME_T \- get the remote time of the retrieved document
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_FILETIME_T,
  9. curl_off_t *timep);
  10. .fi
  11. .SH DESCRIPTION
  12. Pass a pointer to a curl_off_t to receive the remote time of the retrieved
  13. document in number of seconds since January 1 1970 in the GMT/UTC time zone.
  14. If you get \-1, it can be because of many reasons (it might be unknown, the
  15. server might hide it or the server does not support the command that tells
  16. document time etc) and the time of the document is unknown.
  17. You must ask libcurl to collect this information before the transfer is made,
  18. by using the \fICURLOPT_FILETIME(3)\fP option or you unconditionally get a \-1 back.
  19. This option is an alternative to \fICURLINFO_FILETIME(3)\fP to allow systems with 32
  20. bit long variables to extract dates outside of the 32\-bit timestamp range.
  21. .SH PROTOCOLS
  22. This functionality affects ftp, http and sftp
  23. .SH EXAMPLE
  24. .nf
  25. int main(void)
  26. {
  27. CURL *curl = curl_easy_init();
  28. if(curl) {
  29. CURLcode res;
  30. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  31. /* Ask for filetime */
  32. curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
  33. res = curl_easy_perform(curl);
  34. if(CURLE_OK == res) {
  35. curl_off_t filetime;
  36. res = curl_easy_getinfo(curl, CURLINFO_FILETIME_T, &filetime);
  37. if((CURLE_OK == res) && (filetime >= 0)) {
  38. time_t file_time = (time_t)filetime;
  39. printf("filetime: %s", ctime(&file_time));
  40. }
  41. }
  42. /* always cleanup */
  43. curl_easy_cleanup(curl);
  44. }
  45. }
  46. .fi
  47. .SH AVAILABILITY
  48. Added in curl 7.59.0
  49. .SH RETURN VALUE
  50. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  51. .SH SEE ALSO
  52. .BR CURLOPT_FILETIME (3),
  53. .BR curl_easy_getinfo (3),
  54. .BR curl_easy_setopt (3)