\Header{as.POSIX*}{Date-time Conversion Functions}
\alias{as.POSIXct}{as.POSIX*}
\methalias{as.POSIXct.Date}{as.POSIX*}
\methalias{as.POSIXct.date}{as.POSIX*}
\methalias{as.POSIXct.dates}{as.POSIX*}
\methalias{as.POSIXct.default}{as.POSIX*}
\methalias{as.POSIXct.POSIXlt}{as.POSIX*}
\alias{as.POSIXlt}{as.POSIX*}
\keyword{utilities}{as.POSIX*}
\keyword{chron}{as.POSIX*}
\begin{Description}\relax
Functions to manipulate objects of classes \code{"POSIXlt"} and
\code{"POSIXct"} representing calendar dates and times (to the nearest
second).
\end{Description}
\begin{Usage}
\begin{verbatim}
as.POSIXct(x, tz = "")
as.POSIXlt(x, tz = "")

\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] An object to be converted.
\item[\code{tz}] A timezone specification to be used for the conversion,
\emph{if one is required}.  System-specific, but \code{""}
is the current timezone, and \code{"GMT"} is UTC
(Coordinated Universal Time, in French).
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The \code{as.POSIX*} functions convert an object to one of the two
classes used to represent date/times (calendar dates plus time to the
nearest second).  They can take convert a wide variety of objects,
including objects of the other class and of classes \code{"Date"},
\code{"date"} (from package \pkg{\link[date:as.date]{date}} or
\pkg{\link[survival:as.date]{survival}}), \code{"chron"} and
\code{"dates"} (from package \pkg{\link[chron]{chron}}) to these
classes.  Dates are treated as being at midnight UTC.

They can also convert character strings of the formats
\code{"2001-02-03"} and \code{"2001/02/03"} optionally followed by
white space and a time in the format \code{"14:52"} or
\code{"14:52:03"}.  (Formats such as \code{"01/02/03"} are ambiguous
but can be converted via a format specification by
\code{\Link{strptime}}.)

Logical \code{NA}s can be converted to either of the classes, but no
other logical vectors can be.
\end{Details}
\begin{Value}
\code{as.POSIXct} and \code{as.POSIXlt} return an object of the
appropriate class.  If \code{tz} was specified, \code{as.POSIXlt}
will give an appropriate \code{"tzone"} attribute.
\end{Value}
\begin{Note}\relax
If you want to extract specific aspects of a time (such as the day of
the week) just convert it to class \code{"POSIXlt"} and extract the
relevant component(s) of the list, or if you want a character
representation (such as a named day of the week) use
\code{\Link{format.POSIXlt}} or \code{\Link{format.POSIXct}}.

If a timezone is needed and that specified is invalid on your system,
what happens is system-specific but it will probably be ignored.
\end{Note}
\begin{SeeAlso}\relax
\link{DateTimeClasses} for details of the classes;
\code{\Link{strptime}} for conversion to and from character
representations.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
(z <- Sys.time())             # the current date, as class "POSIXct"
unclass(z)                    # a large integer
floor(unclass(z)/86400)       # the number of days since 1970-01-01
(z <- as.POSIXlt(Sys.time())) # the current date, as class "POSIXlt"
unlist(unclass(z))            # a list shown as a named vector

as.POSIXlt(Sys.time(), "GMT") # the current time in GMT
\end{ExampleCode}
\end{Examples}

