CURLOPT_FILETIME(3)

πŸ’… CURLOPT_FILETIME πŸ’…

okay so bestie, welcome to the CURLOPT_FILETIME page β€” that's the libcurl manual, third section, and it's literally all about getting the modification time of a remote thing. yes. timestamps. we love a timestamp. πŸ•°οΈβœ¨


✨ NAME ✨

CURLOPT_FILETIME β€” get the modification time of the remote resource πŸŽ€


✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FILETIME, long gettime);

🌸 DESCRIPTION 🌸

so you pass a long, right? and if that long is 1, libcurl tries to get the modification time of the remote document in this operation. highkey main character behavior. πŸ‘‘

but like β€” heads up β€” this requires that the remote server actually sends the time, or replies to a time querying command. so it's giving "hope for the best," not "guaranteed." πŸ™ˆ

then, after a transfer, you can hit up curl_easy_getinfo(3) with the CURLINFO_FILETIME(3) argument to extract the received time (if any). "if any" is doing a lot of work in that sentence, iykyk. πŸ’€


πŸ¦‹ DEFAULT πŸ¦‹

0

(not me, not asking, not caring β€” unless you say so πŸ’…)


🌈 PROTOCOLS 🌈

this functionality affects file, ftp, http, sftp and smb β€” five icons, all iconic, no cap. ⭐


πŸ’– EXAMPLE πŸ’–

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/path.html");
    /* Ask for filetime */
    curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
    result = curl_easy_perform(curl);
    if(CURLE_OK == result) {
      long filetime;
      result = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
      if((CURLE_OK == result) && (filetime >= 0)) {
        time_t file_time = (time_t)filetime;
        printf("filetime: %s", ctime(&file_time));
      }
    }
    /* always cleanup */
    curl_easy_cleanup(curl);
  }
}

like, look at her go 🫢 ask for the filetime, do the transfer, pull the info, print it with ctime, then clean up. /* always cleanup */ is the golden rule bestie, don't forget it 😭


🧚 AVAILABILITY 🧚

Added in curl 7.5 β€” vintage, but make it cute. πŸŽ€


πŸ”₯ RETURN VALUE πŸ”₯

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK β€” slay. ✨ non-zero means an error occurred, so go check libcurl-errors(3). not the vibe, but at least you'll know what's up πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie!! brought to you by libcurl, dated 2026-10-12 β€” mwah, go get those timestamps πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from