Tutorial by Examples

# test date-time object options(digits.secs = 3) d = as.POSIXct("2016-08-30 14:18:30.58", tz = "UTC") format(d,"%S") # 00-61 Second as integer ## [1] "30" format(d,"%OS") # 00-60.99… Second as fractional ## [1] "30.579" for...
The functions for parsing a string into POSIXct and POSIXlt take similar parameters and return a similar-looking result, but there are differences in how that date-time is stored; see "Remarks." as.POSIXct("11:38", # time string format = "...
To add/subtract time, use POSIXct, since it stores times in seconds ## adding/subtracting times - 60 seconds as.POSIXct("2016-01-01") + 60 # [1] "2016-01-01 00:01:00 AEDT" ## adding 3 hours, 14 minutes, 15 seconds as.POSIXct("2016-01-01") + ( (3 * 60 * 60) + (14 ...

Page 1 of 1