CURLINFO_FILETIME.3 1.8 KB

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