1

I am trying to convert a 13 character UNIX timestamp to datetime and I am getting a year that is in the 44000's. I'm not sure what I am doing wrong, hopefully someone can help.

library(maptools)
GMT <- readShapePoints("~/Documents/Data/Cyber/US/CONTIG_US/UNF01_CONT")
GMT1 <-   as.POSIXct(as.numeric(as.character(GMT$Encoded_Ti)),origin='01-01-1970', tz = 'GMT')
Y <- sample(GMT1, 10, replace = FALSE)
print(Y)

I am grabbing a random sample just to show the results because my file contains 100K+ points. The results I get are as follows:

[1] "44086-01-29 06:33:40 GMT" "44071-01-06 17:21:10 GMT"
[3] "44058-02-21 04:30:10 GMT" "44065-10-06 14:21:40 GMT"
[5] "44061-07-25 17:34:40 GMT" "44038-03-28 21:28:10 GMT"
[7] "44047-07-02 14:27:00 GMT" "44090-04-01 22:37:20 GMT"
[9] "44040-02-16 12:33:40 GMT" "44068-10-08 14:17:20 GMT" 

Does anybody have any ideas as to what I am doing wrong?

closed as off-topic by Jason Scheirer, Mapperz Oct 9 '15 at 16:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions relating to general Information Technology, with no clear GIS component, are off-topic here, but can be researched/asked at Stack Overflow (software development), Super User (computing hardware and software) and Database Administrators (relational databases)" – Jason Scheirer, Mapperz
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Can you provide some of the input timestamps? When you specify a UNIX timestamp I'm expecting an integer value, but the '13 character' description makes me wonder if you have something else... – Evil Genius Oct 9 '15 at 15:06
  • What are your input dates? Edit - oops Evil Genius just asked. – Thomas Oct 9 '15 at 15:06
  • Thank you for replying @EvilGenius I was able to solve my problem using the as.POSIXct function. What I meant to say was 13 integer, I think the 3 extra integers was a because the time was in milliseconds from epoch time. – Michael Oct 12 '15 at 19:16