http_date: Format timestamps to match the HTTP specs

to_http_dateR Documentation

Format timestamps to match the HTTP specs

Description

Dates/times in HTTP headers needs a specific format to be valid, and is furthermore always given in GMT time. These two functions aids in converting back and forth between the required format.

Usage

to_http_date(time, format = NULL)

from_http_date(time)

Arguments

time

A string or an object coercible to POSIXct

format

In case time is not a POSIXct object a specification how the string should be interpreted.

Value

to_http_date() returns a properly formatted string, while from_http_date() returns a POSIXct object

Examples

time <- to_http_date(Sys.time())
time
from_http_date(time)

reqres documentation built on Aug. 19, 2022, 5:18 p.m.