1---
2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLINFO_FILETIME
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_FILETIME (3)
9  - curl_easy_getinfo (3)
10  - curl_easy_setopt (3)
11---
12
13# NAME
14
15CURLINFO_FILETIME - get the remote time of the retrieved document
16
17# SYNOPSIS
18
19~~~c
20#include <curl/curl.h>
21
22CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_FILETIME, long *timep);
23~~~
24
25# DESCRIPTION
26
27Pass a pointer to a long to receive the remote time of the retrieved document
28in number of seconds since January 1 1970 in the GMT/UTC time zone. If you get
29-1, it can be because of many reasons (it might be unknown, the server might
30hide it or the server does not support the command that tells document time
31etc) and the time of the document is unknown.
32
33You must tell libcurl to collect this information before the transfer is made,
34by using the CURLOPT_FILETIME(3) option to curl_easy_setopt(3) or
35you this unconditionally gets a -1 back.
36
37Consider using CURLINFO_FILETIME_T(3) to be able to extract dates beyond
38the year 2038 on systems using 32 bit longs (Windows).
39
40# PROTOCOLS
41
42HTTP(S), FTP(S), SFTP
43
44# EXAMPLE
45
46~~~c
47int main(void)
48{
49  CURL *curl = curl_easy_init();
50  if(curl) {
51    CURLcode res;
52    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
53    /* Ask for filetime */
54    curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
55    res = curl_easy_perform(curl);
56    if(CURLE_OK == res) {
57      long filetime = 0;
58      res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
59      if((CURLE_OK == res) && (filetime >= 0)) {
60        time_t file_time = (time_t)filetime;
61        printf("filetime: %s", ctime(&file_time));
62      }
63    }
64    /* always cleanup */
65    curl_easy_cleanup(curl);
66  }
67}
68~~~
69
70# AVAILABILITY
71
72Added in 7.5
73
74# RETURN VALUE
75
76Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
77