I have an r dataset which has a list of timestamps like this: 2009-08-18 14:38:20 2010-08-10 14:58:25 etc
2009-08-18 14:38:20
2010-08-10 14:58:25
I want to extract the year but the Posixct doesn't have a years function unlike the months(t$timestamp)
months(t$timestamp)
Is there a way to get only 2009?
Use format:
x <- as.POSIXct(c("2009-08-18 14:38:20", "2010-08-10 14:58:25")) format(x, "%Y")
Have you tried ?
strptime(yourtimestamp, "%Y")