xref: /curl/docs/libcurl/opts/CURLOPT_TIMEVALUE.md (revision e3fe0200)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_TIMEVALUE
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_TIMECONDITION (3)
9  - CURLOPT_TIMEVALUE_LARGE (3)
10Protocol:
11  - HTTP
12---
13
14# NAME
15
16CURLOPT_TIMEVALUE - time value for conditional
17
18# SYNOPSIS
19
20~~~c
21#include <curl/curl.h>
22
23CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEVALUE, long val);
24~~~
25
26# DESCRIPTION
27
28Pass a long *val* as parameter. This should be the time counted as seconds
29since 1 Jan 1970, and the time is used in a condition as specified with
30CURLOPT_TIMECONDITION(3).
31
32On systems with 32 bit 'long' variables (such as Windows), this option cannot
33set dates beyond the year 2038. Consider CURLOPT_TIMEVALUE_LARGE(3)
34instead.
35
36# DEFAULT
37
380
39
40# EXAMPLE
41
42~~~c
43int main(void)
44{
45  CURL *curl = curl_easy_init();
46  if(curl) {
47    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
48
49    /* January 1, 2020 is 1577833200 */
50    curl_easy_setopt(curl, CURLOPT_TIMEVALUE, 1577833200L);
51
52    /* If-Modified-Since the above time stamp */
53    curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
54
55    /* Perform the request */
56    curl_easy_perform(curl);
57  }
58}
59~~~
60
61# AVAILABILITY
62
63Always
64
65# RETURN VALUE
66
67Returns CURLE_OK
68