POSIXlt
. The conversion specification (pattern) is looked up if not given as argument.formatTS(time.stamp, pattern)
POSIXlt
vector.POSIXlt
, the usage of formatTS
is not necessary. strptime
can also be used to create an applicable time stamp. Usage of formatTS
is recommeded, since it checks the created time stamp, thus faulty time stamps are avoided.Pattern
A conversion specification is introduced by "%", usually followed by a single letter. Any character in the format string not part of a conversion specification is interpreted literally. Widely implemented conversion specifications include:
%d
: day of the month as decimal number (01--31)%m
: month as decimal number (01--12)%y
: year without century (00--99), where values 00--68 are prefixed by 20 and 69--99 by 19%Y
: year with century%H
: hour as decimal number (00--23)%M
: minute as decimal number (00--59)%S
: second as decimal number (00--61)strptime
.POSIXlt
, strptime
, createMast
# load and prepare data
data(winddata)
# format time stamp
time.stamp <- formatTS(winddata[,1])
# format time stamp with given pattern
time.stamp.2 <- formatTS(winddata[,1], "%d.%m.%Y %H:%M")
# wrong pattern (%y)
time.stamp.2 <- formatTS(winddata[,1], "%d.%m.%y %H:%M")
# very special time stamp pattern
ts <- c("TS 08/2012-10 8h10m30s", "TS 08/2012-10 8h20m30s",
"TS 08/2012-10 8h30m30s")
time.stamp.3 <- formatTS(ts) # pattern not found
time.stamp.3 <- formatTS(ts, "TS %m/%Y-%d %Hh%Mm%Ss")
Run the code above in your browser using DataLab