I have a UTC timestamp. I want to convert it into YYYY/MM/DD format in R
.
For example, 1318394558766
. I tried format
command unsuccessfully.
Any help is appreciated.
Thanks!
I have a UTC timestamp. I want to convert it into YYYY/MM/DD format in R
.
For example, 1318394558766
. I tried format
command unsuccessfully.
Any help is appreciated.
Thanks!
Yet another solution is to use
.POSIXct
:Then you can easily convert
utc
to a Date or character vector:In addition to Justin's answer (and because I can't make comments) you may want to add the tz to the transformation.
For more information see;
You can use
as.POSIXct
oras.POSIXlt
. However you have to know the origin date from which your number of milliseconds started.Then you can use
format
to get the desired YYYY/MM/DD: