Learn R Programming

oce (version 0.9-18)

decodeTime: Decode a time, similar to as.POSIXct()

Description

Decode a time, similar to as.POSIXct()

Usage

decodeTime(time, timeFormats, tz="UTC")

Arguments

time
a character string with an indication of the time
timeFormats
optional vector of time formats to use, as for as.POSIXct
tz
time zone

Value

Details

Each format in timeFormats is used in turn as the format argument to as.POSIXct, and the first that produces a non-NA result is used. If timeFormats is missing, the following formats are tried, in the stated order:
  • "%b %d %Y %H:%M:%S"(e.g."Jul 1 2013 01:02:03") and"%b %d %Y"(e.g."Jul 1 2013")
  • "%B %d %Y %H:%M:%S"(e.g."July 1 2013 01:02:03") and"%B %d %Y"(e.g."July 1 2013")
  • "%d %b %Y %H:%M:%S"(e.g."1 Jul 2013 01:02:03") and"%d %b %Y"(e.g."1 Jul 2013")
  • "%d %B %Y %H:%M:%S"(e.g."1 July 2013 01:02:03") and"%d %B %Y"(e.g."1 July 2013")
  • "%Y-%m-%d %H:%M:%S"(e.g."2013-07-01 01:02:03") and"%Y-%m-%d"(e.g."2013-07-01")
  • "%Y-%b-%d %H:%M:%S"(e.g."2013-July-01 01:02:03") and"%Y-%b-%d"(e.g."2013-Jul-01")
  • "%Y-%B-%d %H:%M:%S"(e.g."2013-July-01 01:02:03") and"%Y-%B-%d"(e.g."2013-July-01")
  • "%d-%b-%Y %H:%M:%S"(e.g."01-Jul-2013 01:02:03") and"%d-%b-%Y"(e.g."01-Jul-2013")
  • "%d-%B-%Y %H:%M:%S"(e.g."01-July-2013 01:02:03") and"%d-%B-%Y"(e.g."01-July-2013")
  • "%Y/%b/%d %H:%M:%S"(e.g."2013/Jul/01 01:02:03") and"%Y/%b/%d"(e.g."2013/Jul/01")
  • "%Y/%B/%d %H:%M:%S"(e.g."2013/July/01 01:02:03") and"%Y/%B/%d"(e.g."2013/July/01")
  • "%Y/%m/%d %H:%M:%S"(e.g."2013/07/01 01:02:03") and"%Y/%m/%d"(e.g."2013/07/01")

Examples

Run this code
decodeTime("July 1 2013 01:02:03")
decodeTime("Jul 1 2013 01:02:03")
decodeTime("1 July 2013 01:02:03")
decodeTime("1 Jul 2013 01:02:03")
decodeTime("2013-07-01 01:02:03")
decodeTime("2013/07/01 01:02:03")
decodeTime("2013/07/01")

Run the code above in your browser using DataLab