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 with CURLOPT_FILETIME(3), or you're getting that -1 and 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