AsDateTime: Parse Character Date-Times to POSIXct Objects

View source: R/asdatetime.R

ParseDateTimeR Documentation

Parse Character Date-Times to POSIXct Objects

Description

Parses date-time character vectors to POSIXct

Usage

ParseDateTime(x, us.format = TRUE, time.zone = "UTC")

AsDateTime(
  x,
  us.format = NULL,
  time.zone = "UTC",
  exact = FALSE,
  on.parse.failure = "error"
)

Arguments

x

A character vector of dates with timestamps, which should all be in the same format (excluding missing values). Can also be of class Date or POSIXlt, in which case it will be coerced to POSIXct using as.POSIXct.

us.format

logical; whether to use the US convention for dates; can be NULL in which case both U.S. formats and international formats will be checked

time.zone

An optional time zone (default "UTC").

exact

see parse_date_time2

on.parse.failure

Character string specifying how parse failures should be handled; "error", the default, results in an error being thrown with stop in the event that x cannot be parsed; specifying "warn" results in a warning be thrown and a vector of NA values with the same length as x; any other value results in a vector of NAs being returned silently.

Details

ParseDateTime is deprecated and merely calls AsDateTime

Value

A vector of POSIXct date-time objects, if all elements of x have the same, valid format; otherwise, when on.parse.failure is not "error", a vector of NA values with the same length as x.

References

See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a list of time zones.

See Also

parse_date_time2, DateTimeClasses

Examples

AsDateTime("1-2-2017 12:34:56", us.format = FALSE)
AsDateTime(c("2018-06-19T16:45:30.045Z", "2018-06-20T06:12:34.125+06"))

Displayr/flipTime documentation built on Feb. 26, 2024, 12:46 a.m.