1curl_getdate(3)                 libcurl Manual                 curl_getdate(3)
2
3
4

NAME

6       curl_getdate - Convert a date string to number of seconds
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       time_t curl_getdate(char *datestring, time_t *now);
12

DESCRIPTION

14       curl_getdate(3)  returns the number of seconds since the Epoch, January
15       1st 1970 00:00:00 in the UTC time zone, for the date and time that  the
16       datestring  parameter  specifies. The now parameter is not used, pass a
17       NULL there.
18
19       This function works with valid dates and does not always detect and re‐
20       ject wrong dates, such as February 30.
21
22

PARSING DATES AND TIMES

24       A  "date" is a string containing several items separated by whitespace.
25       The order of the items is immaterial. A date string  may  contain  many
26       flavors of items:
27
28       calendar date items
29               Can  be  specified several ways. Month names can only be three-
30               letter English abbreviations, numbers can be zero-prefixed  and
31               the  year  may  use  2  or  4  digits.   Examples: 06 Nov 1994,
32               06-Nov-94 and Nov-94 6.
33
34       time of the day items
35               This string specifies the time on a given day. You must specify
36               it  with 6 digits with two colons: HH:MM:SS. To not include the
37               time in a date string, will make the function assume  00:00:00.
38               Example: 18:19:21.
39
40       time zone items
41               Specifies  international  time  zone.  There are a few acronyms
42               supported, but in general you should instead use  the  specific
43               relative  time  compared  to  UTC.  Supported  formats include:
44               -1200, MST, +0100.
45
46       day of the week items
47               Specifies a day of the week. Days of the week  may  be  spelled
48               out  in  full  (using English): `Sunday', `Monday', etc or they
49               may be abbreviated to their first three letters. This  is  usu‐
50               ally not info that adds anything.
51
52       pure numbers
53               If  a decimal number of the form YYYYMMDD appears, then YYYY is
54               read as the year, MM as the month number and DD as the  day  of
55               the month, for the specified calendar date.
56

EXAMPLE

58        time_t t;
59        t = curl_getdate("Sun, 06 Nov 1994 08:49:37 GMT", NULL);
60        t = curl_getdate("Sunday, 06-Nov-94 08:49:37 GMT", NULL);
61        t = curl_getdate("Sun Nov  6 08:49:37 1994", NULL);
62        t = curl_getdate("06 Nov 1994 08:49:37 GMT", NULL);
63        t = curl_getdate("06-Nov-94 08:49:37 GMT", NULL);
64        t = curl_getdate("Nov  6 08:49:37 1994", NULL);
65        t = curl_getdate("06 Nov 1994 08:49:37", NULL);
66        t = curl_getdate("06-Nov-94 08:49:37", NULL);
67        t = curl_getdate("1994 Nov 6 08:49:37", NULL);
68        t = curl_getdate("GMT 08:49:37 06-Nov-94 Sunday", NULL);
69        t = curl_getdate("94 6 Nov 08:49:37", NULL);
70        t = curl_getdate("1994 Nov 6", NULL);
71        t = curl_getdate("06-Nov-94", NULL);
72        t = curl_getdate("Sun Nov 6 94", NULL);
73        t = curl_getdate("1994.Nov.6", NULL);
74        t = curl_getdate("Sun/Nov/6/94/GMT", NULL);
75        t = curl_getdate("Sun, 06 Nov 1994 08:49:37 CET", NULL);
76        t = curl_getdate("06 Nov 1994 08:49:37 EST", NULL);
77        t = curl_getdate("Sun, 12 Sep 2004 15:05:58 -0700", NULL);
78        t = curl_getdate("Sat, 11 Sep 2004 21:32:11 +0200", NULL);
79        t = curl_getdate("20040912 15:05:58 -0700", NULL);
80        t = curl_getdate("20040911 +0200", NULL);
81

STANDARDS

83       This  parser  handles  date formats specified in RFC 822 (including the
84       update in RFC 1123) using time zone name or time zone delta and RFC 850
85       (obsoleted by RFC 1036) and ANSI C's asctime() format.
86
87       These  formats  are  the  only ones RFC 7231 says HTTP applications may
88       use.
89

AVAILABILITY

91       Always
92

RETURN VALUE

94       This function returns -1 when it fails to parse the date string. Other‐
95       wise it returns the number of seconds as described.
96
97       On systems with a signed 32 bit time_t: if the year is larger than 2037
98       or less than 1903, this function will return -1.
99
100       On systems with an unsigned 32 bit time_t: if the year is  larger  than
101       2106 or less than 1970, this function will return -1.
102
103       On  systems  with  64  bit  time_t: if the year is less than 1583, this
104       function will return -1. (The Gregorian calendar was  first  introduced
105       1582  so  no  "real"  dates  in  this way of doing dates existed before
106       then.)
107

SEE ALSO

109       curl_easy_escape(3),  curl_easy_unescape(3),  CURLOPT_TIMECONDITION(3),
110       CURLOPT_TIMEVALUE(3)
111
112
113
114libcurl 8.0.1                  January 02, 2023                curl_getdate(3)
Impressum