1

I use lubridate to define a date, which does not contain hour, minute and second. The code is below:

library(lubridate)
start_date <- as.POSIXct("1980-1-1")
> start_date
[1] "1980-01-01 CST"

I want to add the time information "0:00:00" to it. That is, start_date is now "1980-01-01 0:00:00". How to make it? I want start_date still a Date form (i.e., ymd_hms), not a character.

T X
  • 505
  • 1
  • 9
  • 19
  • 1
    The time information is there, it's just not printed. Try `start_date + 1`. Side note: you don't need `lubridate` for the code shown. – Henrik Feb 23 '19 at 13:20
  • 1
    Under the hood `print.POSIXct` calls `format`. From `?format`: "The default for the format methods is `"%Y-%m-%d %H:%M:%S"` if any element has a time component which is not midnight, and `"%Y-%m-%d"` otherwise. – Henrik Feb 23 '19 at 13:26

0 Answers0