CURLINFO_FILETIME_T(3)

πŸ’… CURLINFO_FILETIME_T(3) β€” like, the libcurl manual, bestie πŸŽ€

okay so picture this: you're deep in the Library Functions Manual section of the libcurl pages, and you just found the one that tells you when a remote file was last touched. iconic behavior only. let's go ✨


🌸 NAME 🌸

CURLINFO_FILETIME_T β€” the remote time of the retrieved resource, but make it 64-bit-safe πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <curl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_FILETIME_T,
                           curl_off_t *timep);

✨ DESCRIPTION ✨

so basically πŸ‘‘ β€” you pass in a pointer to a curl_off_t, and it receives the remote time of the document you just retrieved. that's the number of seconds since January 1 1970, in the GMT/UTC time zone. periodt.

if you get back -1, don't panic 😭 β€” there are like a million reasons that can happen. it might just be unknown, the server might be hiding it from you (rude), or the server might not even support the command that reports document time, etc etc. either way, the time of the document is unknown. that's it, that's the whole vibe.

⚠️ bestie, listen β€” you must ask libcurl to collect this info before the transfer is made, by using the CURLOPT_FILETIME(3) option. if you don't, you unconditionally get a -1 back. no cap. πŸ™ˆ

and here's the slay πŸ’… β€” this option is an alternative to CURLINFO_FILETIME(3), specifically so that systems with 32 bit long variables can still extract dates outside of the 32-bit timestamp range. it's giving "we thought of everything." 🧚


🌈 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) {
      curl_off_t filetime;
      result = curl_easy_getinfo(curl, CURLINFO_FILETIME_T, &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);
  }
}

like, look at her go πŸ˜­πŸ’– she sets the URL, asks for the filetime, performs, then grabs the curl_off_t and prints it with ctime. main character energy fr fr.


🫢 AVAILABILITY 🫢

added in curl 7.59.0 ⭐


πŸ‘‘ RETURN VALUE πŸ‘‘

curl_easy_getinfo(3) returns a CURLcode that indicates success or error.

  • CURLE_OK (0) means everything was OK πŸ’š
  • non-zero means an error occurred β€” go check libcurl-errors(3) πŸ”

πŸ’œ SEE ALSO πŸ’œ


okay that's the whole page, you ate that 🍽️✨ go forth and timestamp responsibly. this little love letter comes to you from libcurl, dated 2026-10-12, and it's forever filed under CURLINFO_FILETIME_T(3) πŸ’…πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from