Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

parse_http_date

Parse and print http dates.


Description

As defined in RFC2616, http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3, there are three valid formats:

  • Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123

  • Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036

  • Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format

Usage

parse_http_date(x, failure = structure(NA_real_, class = "Date"))

http_date(x)

Arguments

x

For parse_http_date, a character vector of strings to parse. All elements must be of the same type.

For http_date, a POSIXt vector.

failure

What to return on failure?

Value

A POSIXct object if succesful, otherwise failure

Examples

parse_http_date("Sun, 06 Nov 1994 08:49:37 GMT")
parse_http_date("Sunday, 06-Nov-94 08:49:37 GMT")
parse_http_date("Sun Nov  6 08:49:37 1994")

http_date(Sys.time())

httr

Tools for Working with URLs and HTTP

v1.4.2
MIT + file LICENSE
Authors
Hadley Wickham [aut, cre], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.