I want to convert "2013-09-16" into unix time.
I found Convert UNIX epoch to Date object in R but I need to do the reverse of that.
Thanks!
I want to convert "2013-09-16" into unix time.
I found Convert UNIX epoch to Date object in R but I need to do the reverse of that.
Thanks!
Quite simple:
as.numeric(as.POSIXct("2013-09-16 2:13:46 EST"))
Simply cast to numeric:
as.numeric(as.POSIXct("2013-09-06", format="%Y-%m-%d"))
# [1] 1378418400
This tipe of time is useful for YahooFinance i'll leave you a code if you want to see 60 days before until today:
window <- 60
tempo<-as.character(Sys.time())
substr(time, 12, 24) <- "00:00:00"
tempo<-as.POSIXct(tempo)
end_date <- ceiling(as.numeric(as.POSIXct(tempo)))
start_date <- ceiling(as.numeric(as.POSIXct(tempo - window*86400)))
This code will give you an interval for download the time that you want.
WAC.