CURLOPT_TIMEVALUE(3)

πŸ’… CURLOPT_TIMEVALUE(3)

okay so bestie, welcome to CURLOPT_TIMEVALUE β€” a page from the Library Functions Manual that's literally all about setting a timestamp for your conditional requests. it's short, it's sweet, and it's giving "small but mighty" energy. let's get into it πŸŽ€


✨ NAME ✨

CURLOPT_TIMEVALUE β€” the time value for a conditional, no cap πŸ•°οΈ


✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEVALUE, long val);

✨ DESCRIPTION ✨

so you pass a long called val as the parameter, right? this is supposed to be the time counted as seconds since 1 Jan 1970 (yes, the epoch, she's iconic), and that time gets used in a condition β€” specifically whichever condition you set up with CURLOPT_TIMECONDITION(3). 🫢

🚨 big heads up 🚨 on systems with 32-bit long variables (Windows, i'm looking at you πŸ‘€), this option cannot set dates beyond the year 2038. that's the whole Y2K38 vibe and it's not a slay. consider CURLOPT_TIMEVALUE_LARGE(3) instead, fr fr.

✨ DEFAULT ✨

0


✨ PROTOCOLS ✨

this functionality affects http only β€” that's the vibe check, she's an http-only girlie ✨


✨ EXAMPLE ✨

okay here's the whole thing in action, copy-paste ready πŸ’–

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);
  }
}

like, 1577833200L is January 1, 2020, and then CURL_TIMECOND_IFMODSINCE makes it an If-Modified-Since situation. main character behavior honestly πŸ‘‘


✨ HISTORY ✨

CURL_TIMECOND_* enums became long types in 8.13.0 β€” before that version, a long cast was necessary when passed to curl_easy_setopt(3). so if you're on old curl, casting was the move. glow-up achieved πŸ’…


✨ AVAILABILITY ✨

added in curl 7.1 β€” she's been around, she's a veteran 🫑


✨ RETURN VALUE ✨

curl_easy_setopt(3) returns a CURLcode indicating success or error, bestie. that's it.

  • CURLE_OK (0) means everything was OK 🌈
  • non-zero means an error occurred 😭 β€” go check libcurl-errors(3) for the deets

✨ SEE ALSO ✨


libcurl Β· 2026-10-12 β€” that's the source, the version, and the date all wrapped up in a little bow πŸŽ€ tysm for reading, go set some timestamps, ily, bye!! πŸ’–βœ¨

πŸ“¦ where this page comes from