I need to convert a vector of dates from Unix Time to Date format using R. For more context, this dates come from Sentinel-2 satellite imagery time series with one image every five days. The time series starts on 2020/01/01.
dates <- c(1577876409428, 1578308409796, 1578740409279, 1579172409017, 1579604408531)
I'm trying to convert to date using as follows:
library(lubridate)
new_date <- as.Date(as.POSIXct(dates, origin="1970-01-01"))
However, I get wrong results:
"51970-11-30" "51984-08-08" "51998-04-17" "52011-12-25" "52025-09-02"
Copyright License:
Author:「sermomon」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/74987560/unix-time-to-date-in-r