CURLINFO_FILETIME(3)
β¨ CURLINFO_FILETIME β¨
okay so bestie, you're reading the CURLINFO_FILETIME(3) page from the Library Functions Manual, and it's literally all about grabbing the remote time of a retrieved document. no cap, this one is kinda niche but also iconic when you need it π
πΈ SYNOPSIS πΈ
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_FILETIME, long *timep);
π DESCRIPTION π
So here's the vibe: you pass a pointer to a long, and it receives the remote time of the retrieved document in number of seconds since January 1 1970 in the GMT/UTC time zone. that's the whole main character move π°οΈβ¨
If you get -1, it can be because of many reasons β it might be unknown, the server might hide it, or the server does not support the command that tells document time etc β and the time of the document is unknown. so yeah, -1 is giving "mystery era" π
You must ask libcurl to collect this information before the transfer is made, by using the CURLOPT_FILETIME(3) option, or you unconditionally get a -1 back. like, no asky-no filetime, periodt π
Consider CURLINFO_FILETIME_T(3) instead to be able to extract dates beyond the year 2038 on systems using 32-bit longs (Windows). this is your "future-proofing era" reminder π«Ά
π¦ PROTOCOLS π¦
This functionality affects ftp, http and sftp π
π EXAMPLE π
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Ask for filetime */
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
result = curl_easy_perform(curl);
if(CURLE_OK == result) {
long filetime = 0;
result = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
if((CURLE_OK == result) && (filetime != -1)) {
time_t file_time = (time_t)filetime;
printf("filetime: %s", ctime(&file_time));
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
π AVAILABILITY π
Added in curl 7.5 β
π RETURN VALUE π
curl_easy_getinfo(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3). that's the whole "good vibes only vs. not" check π
π SEE ALSO π
okay bestie, quick vibe check: don't forget to ask for filetime before the transfer withCURLOPT_FILETIME(3), or you're getting that-1and the mystery is not cute ππ
mwah π β this little page comes from libcurl, dated 2026-10-12, and it's still serving CURLINFO_FILETIME(3) energy. slay β¨
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms