[R] convert 12 time stamp to 24 hour

arun smartpink111 at yahoo.com
Fri Feb 8 15:15:34 CET 2013


Hi,
library(lubridate)
 ymd_hms(testtime)
 1 parsed with %Y-%m-%d %I:%M:%S %p
#[1] "2013-01-01 13:00:01 UTC"
A.K.




----- Original Message -----
From: e-letter <inpost at gmail.com>
To: r-help at r-project.org
Cc: 
Sent: Friday, February 8, 2013 4:44 AM
Subject: [R] convert 12 time stamp to 24 hour

Readers,

For a 12 hour time stamp:

> testtime<-("2013-01-01 01:00:01 PM")
> testtime
[1] "2013-01-01 01:00:01 PM"
> testtime24hour<-strftime(testtime,'%H:%M:%S')
> testtime24hour
[1] "01:00:01"

how to convert to 24 hour format so that the object 'testtime24hour' is:

'13:00:01'

Thanks.

--
r2151

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list