Unix time to Date in R

2023-01-03T06:27:24

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

About “Unix time to Date in R” questions

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!
I have a dataframe which has a column (expires) with unix time codes. I want to convert these to TWO separate columns, one for time (expires_time) and one for date (expires_date). I've started with a
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 s...
Trying to convert a full column of Unix into date time in R. I've been able to use as.POSIXlt(x, origin = "1970-01-01") to convert Unix. But now I'm trying to convert a whole column of Unix into ...
How to change unix time OR long time to date time and date time to unix time OR long time. in PHP and html
I have the following UNIX time string: "1575824800.169" If you convert this time you will get: 12/08/2019 17:06 on an online unix converter. However when trying to convert this in R using the
So I have a form for creating scheduled dates. Title, Subject, bla bla... But then, I have a jQuery Date picker, that lets the user pick a date off a calendar. The jQuery date picker only formats for
Usually we see people converting unix-timestamps into date objects - is it possible to do the reverse instead? For example, given the following date 12-02-2019 00:00:00 convert this into unix ...
I want to replace all the UNIX time in a a JSON data file with the same UNIX time followed by a human readable date format. For example, I want to replace "1234567890123456" (time in microsecond) ...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.