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