[R] how to convert seconds to 12 hour time format
Henrique Dallazuanna
wwwhsd at gmail.com
Tue Apr 10 03:06:16 CEST 2012
Try this:
Sys.setlocale(category = "LC_TIME", locale = "US")
format(as.POSIXct('0001-01-01 00:00:00') + x, "%I:%M:%S %p")
On Mon, Apr 9, 2012 at 9:38 PM, cassie jones <cassiejones26 at gmail.com> wrote:
>
> Hello everyone,
>
> I am wondering if there is any routine in R which can convert time given in
> 'seconds' unit to the 12 hour time format. For example, suppose the data
> set looks like
>
> x=c(36885,84000,20) #x in seconds
>
> I want to get the output as
>
> [1] " 11:14:45 AM"
> [2] " 11:20:00 PM"
> [3] "12:20:00 AM"
>
> Does anyone have any idea? Thanks in advance.
>
>
> Cassie
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
More information about the R-help
mailing list