strptime

date functions in R return wrong year

半世苍凉 提交于 2020-01-30 09:24:26
问题 I am trying to convert a character field into a date field for which the options are to either use strptime function or as.Date function. Here is two reproducible examples: strptime(c("5/13/2015"),"%m/%d/%y") #result is "2020-05-13 MST" as.Date(c("5/13/2015"), format = "%m/%d/%y") #result is "2020-05-13" Why did the functions change the year from 2015 to 2020? If instead, I format my date string and use the as.Date function it works. Here is what I did: as.Date(c("2015/5/13")) and it works

Sortable, readable and standard time format for logs

∥☆過路亽.° 提交于 2020-01-14 09:09:44
问题 Timestamp format in logs Most log lines contain a timestamp and event description: [When] [What] e.g.: [23/Jul/2013:19:35:11 +0000] Processing started. [23/Jul/2013:19:36:11 +0000] Processed 1000 items. [23/Jul/2013:19:37:11 +0000] Processing finished successfully. I am trying to find a standard timestamp for my log lines. My criteria is: Human readable . I want to easily understand when did the event happen. Alphabetically sortable . When I grep events from a few files and sort them using

Sortable, readable and standard time format for logs

做~自己de王妃 提交于 2020-01-14 09:04:18
问题 Timestamp format in logs Most log lines contain a timestamp and event description: [When] [What] e.g.: [23/Jul/2013:19:35:11 +0000] Processing started. [23/Jul/2013:19:36:11 +0000] Processed 1000 items. [23/Jul/2013:19:37:11 +0000] Processing finished successfully. I am trying to find a standard timestamp for my log lines. My criteria is: Human readable . I want to easily understand when did the event happen. Alphabetically sortable . When I grep events from a few files and sort them using

Getting an error “number of items to replace is not a multiple of replacement length”

六月ゝ 毕业季﹏ 提交于 2020-01-14 07:52:21
问题 I'm trying to convert a record into a date and time format using the strptime function. However, I'm not sure why I'm getting the error: number of items to replace is not a multiple of replacement length. I tried to check the length of the record using the length function but both have the same length. data <- DT head(data[6]) # column # 1 2014-12-22 23:53:48 # 2 2014-12-22 23:20:34 # 3 2014-12-22 23:20:30 # 4 2014-12-22 23:20:16 # 5 2014-12-22 23:20:07 # 6 2014-12-22 23:05:49 data[,6] <- as

Parse timestamp with a.m./p.m

折月煮酒 提交于 2020-01-12 14:33:29
问题 I have a file that formats time stamps like 25/03/2011 9:15:00 p.m. How can I parse this text to a Date-Time class with either strptime or as.POSIXct? Here is what almost works: > as.POSIXct("25/03/2011 9:15:00", format="%d/%m/%Y %I:%M:%S", tz="UTC") [1] "2011-03-25 09:15:00 UTC" Here is what is not working, but I'd like to have working: > as.POSIXct("25/03/2011 9:15:00 p.m.", format="%d/%m/%Y %I:%M:%S %p", tz="UTC") [1] NA I'm using R version 2.13.2 (2011-09-30) on MS Windows. My working

Parse timestamp with a.m./p.m

与世无争的帅哥 提交于 2020-01-12 14:31:55
问题 I have a file that formats time stamps like 25/03/2011 9:15:00 p.m. How can I parse this text to a Date-Time class with either strptime or as.POSIXct? Here is what almost works: > as.POSIXct("25/03/2011 9:15:00", format="%d/%m/%Y %I:%M:%S", tz="UTC") [1] "2011-03-25 09:15:00 UTC" Here is what is not working, but I'd like to have working: > as.POSIXct("25/03/2011 9:15:00 p.m.", format="%d/%m/%Y %I:%M:%S %p", tz="UTC") [1] NA I'm using R version 2.13.2 (2011-09-30) on MS Windows. My working

Parse timestamp with a.m./p.m

妖精的绣舞 提交于 2020-01-12 14:30:29
问题 I have a file that formats time stamps like 25/03/2011 9:15:00 p.m. How can I parse this text to a Date-Time class with either strptime or as.POSIXct? Here is what almost works: > as.POSIXct("25/03/2011 9:15:00", format="%d/%m/%Y %I:%M:%S", tz="UTC") [1] "2011-03-25 09:15:00 UTC" Here is what is not working, but I'd like to have working: > as.POSIXct("25/03/2011 9:15:00 p.m.", format="%d/%m/%Y %I:%M:%S %p", tz="UTC") [1] NA I'm using R version 2.13.2 (2011-09-30) on MS Windows. My working