[R] convert 12 time stamp to 24 hour

Pascal Oettli kridox at ymail.com
Fri Feb 8 11:08:13 CET 2013


Hello,

Try this:

 > testtime<-("2013-01-01 01:00:01 PM")
 > strptime(testtime, "%Y-%m-%d %I:%M:%S %p")
[1] "2013-01-01 13:00:01"

HTH,
Pascal


Le 08/02/2013 18:44, e-letter a écrit :
> 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