how to convert seconds to 12 hour time format

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

how to convert seconds to 12 hour time format

cassie jones
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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: how to convert seconds to 12 hour time format

Henrique Dallazuanna
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 <[hidden email]> 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]]
>
> ______________________________________________
> [hidden email] 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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: how to convert seconds to 12 hour time format

cassie jones
Thanks Henrique.....It worked!!! I appreciate your help.

Cassie

On Mon, Apr 9, 2012 at 8:06 PM, Henrique Dallazuanna <[hidden email]>wrote:

> 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 <[hidden email]>
> 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]]
> >
> > ______________________________________________
> > [hidden email] 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
>
        [[alternative HTML version deleted]]


______________________________________________
[hidden email] 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.