Skip to content
Back to formatted view

Raw Message

Message-ID: <87d2ra8u25.fsf@enricoschumann.net>
Date: 2013-06-25T08:37:38Z
From: Enrico Schumann
Subject: Time of day
In-Reply-To: <CAEorq2OYsHgNQkvwtc-C-ABxQPX7uahsCZAoH9F8sgZ1RCcBew@mail.gmail.com> (rguy@123mail.org's message of "Tue, 25 Jun 2013 06:59:02 +0100")

On Tue, 25 Jun 2013, Rguy <rguy at 123mail.org> writes:

> Is there a simple way to obtain the time of day in R? I want the time of
> day for computational purposes, not for display. I want to be able to
> create code like the following:
>
> if (time_of_day >= 22:00 & time_of_day <= 06:00) then X otherwise Y
                     ^^^^^                  ^^^^^
this will not work: the times need to be something that R understands,
eg, numeric values such as 2200 or character values such as "22:00"

>
> I realize I could parse a date/time object and extract the time, but
> hopefully other people have already done this, or there is a
> straightforward representation of time of day in R that I  have not been
> able to find in the documentation.

strftime(Sys.time(), "%H:%M")

-- 
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net