CURLOPT_TIMECONDITION(3)

CURLOPT_TIMECONDITION πŸ’…

okay bestie, this page is CURLOPT_TIMECONDITION(3) from the Library Functions Manual β€” and it's literally about choosing the condition for a time request. let's go ✨

πŸ’– NAME πŸ’–

CURLOPT_TIMECONDITION β€” select condition for a time request

🌸 SYNOPSIS 🌸

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMECONDITION, long cond);

πŸ¦‹ DESCRIPTION πŸ¦‹

So you pass a long as the parameter, mkay? This defines how the CURLOPT_TIMEVALUE(3) time value is treated. You can set this parameter to CURL_TIMECOND_IFMODSINCE or CURL_TIMECOND_IFUNMODSINCE. periodt πŸ’…

Quick reality check, bestie: the last modification time of a file is not always known 😭 and in such instances this feature has no effect even if the given time condition would not have been met. To learn if a zero-byte successful "transfer" was due to this condition not matching, you can use curl_easy_getinfo(3) with the CURLINFO_CONDITION_UNMET option after a transfer. no cap, that's the whole vibe check 🫢

πŸŽ€ DEFAULT πŸŽ€

CURL_TIMECOND_NONE (0) β€” that's the default, bestie ✨

🌈 PROTOCOLS 🌈

This functionality affects file, ftp and http πŸ¦‹

πŸ”₯ EXAMPLE πŸ”₯

Here's the example in all its glory β€” copied exactly because we do not mess with code:

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");

    /* January 1, 2020 is 1577833200 */
    curl_easy_setopt(curl, CURLOPT_TIMEVALUE, 1577833200L);

    /* If-Modified-Since the above time stamp */
    curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);

    /* Perform the request */
    curl_easy_perform(curl);
  }
}

πŸ‘‘ HISTORY πŸ‘‘

CURL_TIMECOND_* enums became long types in 8.13.0; prior to this version a long cast was necessary when passed to curl_easy_setopt(3). history lesson served, iykyk πŸ’œ

✨ AVAILABILITY ✨

Added in curl 7.1 🌸

πŸ’€ RETURN VALUE πŸ’€

curl_easy_setopt(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). fr fr, check the error code 🫢

πŸ’œ SEE ALSO πŸ’œ

CURLINFO_FILETIME(3), CURLOPT_TIMEVALUE(3) β€” go read these next, bestie 🌟


source/version: libcurl, date: 2026-10-12, page: CURLOPT_TIMECONDITION(3) β€” bye bestie, go set some time conditions πŸ’…πŸŽ€

πŸ“¦ where this page comes from