Reputation: 35
This is to get current time . I need to get something like 2021-02-08 12:33:04.txt file
library(lubridate)
t <- Sys.time()
cat(t,"\n")
timeStamp <- strftime(t,"%Y-%m-%d %H:%M:%S")
c<-as.character(str(as.POSIXlt(timeStamp)))
writeLines(paste(timeStamp,"\n",user.str_input), "timeStamp.txt")
Upvotes: 1
Views: 190
Reputation: 9247
I'm afraid you cannot write colons (:
) in .txt file names.
One possible workaround is to eliminate colons from the file name, i.e.
writeLines('HELLO', paste0(gsub(':', '', timeStamp), '.txt'))
Upvotes: 1