0

Sorry if this is not a good question. I am working with a time series and I want to convert the integral time format downloaded in a file like "20150710" to the POSIXct time format which is the absolute number of seconds from the origin "1970-01-01" to the time given. My plan is first convert this integral time to some conventional format in character like "2015-07-10", and then use R function as.POSIXct to get the final answer. Right now I have difficulty to convert it into character. Does anyone have any other solution or any idea about my solution?

Many thanks,

SabDeM
  • 7,050
  • 2
  • 25
  • 38
user45668
  • 31
  • 5
  • I've posted a solution; next time provide a piece of your data and not just what you are trying to achieve. – SabDeM Jul 19 '15 at 11:02

1 Answers1

1

Using strptime, you don't need to convert your string to a different format - you can specify your own format string such as:

strptime('20150710', format = '%Y%m%d')
  • Thanks for the reply, I actually tried to use strptime function, but I mistype the argument as strptime('20150710', format = '%y%m%d'), which won't work. After capitalizing the y it works perfectly fine. – user45668 Jul 19 '15 at 15:17