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

PARSING DATES AND TIMES

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

EXAMPLE

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

STANDARDS

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

AVAILABILITY

85       Always
86

RETURN VALUE

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

SEE ALSO

103       curl_easy_escape(3),  curl_easy_unescape(3),  CURLOPT_TIMECONDITION(3),
104       CURLOPT_TIMEVALUE(3)
105
106
107
108libcurl 7.82.0                 February 01, 2022               curl_getdate(3)
Impressum