Extract date and time from unix timestamp in R

r
data_wrangling

#1

Hello,

I have timestamp in my data in the UNIX format from which I want to extract date and time as they would be of more use to me than the timestamp.
(let an example for a timestamp be 1372657859)
How can I perform this task in R?

Thanks


#2

That should answer your question.


#3
> value <- 1372657859
> 
> as.Date(as.POSIXct(value, origin="1970-01-01"))
[1] "2013-07-01"

#4
> as.POSIXct(value, origin="1970-01-01")
[1] "2013-07-01 11:20:59 IST"

then use lubridate package


#5

It resolved the issue I was facing while dealing with timestamp


#6

convert 1509256348059000 it wont happen


#7

In a blank cell next to your timestamp list and type this formula =(((A1/60)/60)/24)+DATE(1970,1,1), press Enter key, then drag the auto fill handle to a range you need.