Sys.time {base}R Documentation

Get Current Date, Time and Timezone

Description

Sys.time and Sys.Date returns the system's idea of the current date with and without time, and Sys.timezone returns the current time zone.

Usage

Sys.time()
Sys.Date()
Sys.timezone()

Details

Sys.time returns an absolute date-time value which can be converted in various time zones and may return different days.

Sys.Date returns the day in the current timezone.

Value

Sys.time returns an object of class "POSIXct" (see DateTimeClasses). On some systems it will have sub-second accuracy, but on others it will increment in seconds. On Windows, it increments in clock ticks (1/60 of a second) reported to millisecond accuracy.
Sys.Date returns an object of class "Date" (see Date).
Sys.timezone returns an OS-specific character string, possibly an empty string. It may be possible to set the timezone via the environment variable "TZ": see as.POSIXlt. Windows is notorious for naming its timezones differently from the official names.

See Also

date for the system time in a fixed-format character string; the elapsed time component of proc.time for possibly finer resolution in changes in time.

Examples

Sys.time()
## print with possibly greater accuracy:
op <- options(digits.secs=6)
Sys.time()
options(op)

## locale-specific version of date()
format(Sys.time(), "%a %b %d %X %Y")

Sys.Date()

Sys.timezone()

[Package base version 2.4.1 Index]