If you have both date and time information in the numeric value, then use as.POSIXct
. Data.table package IDateTime format is such a case. If you use fwrite
to save a file, the package automatically converts date-times to idatetime format which is unix time. To convert back to normal format following can be done.
Example: Let's say you have a unix time stamp with date and time info: 1442866615
> as.POSIXct(1442866615,origin="1970-01-01")
[1] "2015-09-21 16:16:54 EDT"