now
Signature and parameters
now(tzone = "")
now() accepts a single argument:
| Parameter | Type | Default | Description |
|---|---|---|---|
tzone | character | "" (empty string) | An IANA timezone string. Defaults to your machine’s system timezone. |
Valid timezone strings include "UTC", "America/New_York", "Europe/London", and "GMT". Passing "" (the default) uses the system timezone.
Return value
Returns a single-length POSIXct vector representing the current instant. The returned object has class c("POSIXct", "POSIXt") and base type double, the underlying value is seconds since the Unix epoch (1970-01-01 00:00:00 UTC).
library(lubridate)
class(now())
# [1] "POSIXct" "POSIXt"
typeof(now())
# [1] "double"
The tzone attribute of the returned object reflects the requested timezone. This matters when you store timestamps in a database or share them across systems. A POSIXct stored in one timezone carries its offset information, so downstream consumers can convert it correctly. If you omit an explicit timezone, the timestamp is pinned to whatever zone the machine happened to be using at capture time, which can cause off-by-hours errors when code moves between servers.
Timezones
By default, now() uses your machine’s local timezone. It is not guaranteed to return UTC.
library(lubridate)
# System timezone (default)
now()
# [1] "2026-03-20 09:12:00 EDT"
# Explicit UTC
now("UTC")
# [1] "2026-03-20 13:12:00 UTC"
# Named timezone
now("America/New_York")
# [1] "2026-03-20 09:12:00 EDT"
now("UTC") and now("America/New_York") represent the same instant in time. Only the printed display differs. Comparisons between them work correctly because the underlying numeric representation is absolute. To verify this yourself, capture both values and compare them with ==. The equality holds because each POSIXct stores the same number of seconds since the Unix epoch regardless of how the timezone attribute formats the display.
now("UTC") == now("America/New_York")
# [1] TRUE
Passing an invalid timezone string raises an error. Always validate timezone strings before use if they come from user input. Once you have a POSIXct from now(), you can pull apart its components without any intermediate conversion, using lubridate’s family of extractor functions like year(), month(), and wday().
Extracting components
now() returns a POSIXct, so it composes directly with lubridate’s extractor functions:
library(lubridate)
t <- now("UTC")
year(t) # 2026
month(t) # 3
day(t) # 20
hour(t) # 9
minute(t) # 12
second(t) # 0
wday(t) # 6 (Friday, locale-dependent)
tz(t) # "UTC"
No conversion step is required, pass the POSIXct returned by now() directly. Beyond extracting individual components, you can perform date arithmetic on the result. Adding or subtracting lubridate periods shifts the timestamp forward or backward in time while preserving the timezone attribute.
Time arithmetic
now() returns a POSIXct, so you can add or subtract periods directly:
library(lubridate)
t <- now("UTC")
t
# [1] "2026-03-20 09:12:00 UTC"
t - hours(1)
# [1] "2026-03-20 08:12:00 UTC"
t + days(1)
# [1] "2026-03-21 09:12:00 UTC"
floor_date(t, unit = "day")
# [1] "2026-03-20 00:00:00 UTC"
Use floor_date(), ceiling_date(), or round_date() to align to time boundaries. While now() is straightforward to use, several behaviours trip up even experienced R users. The following gotchas cover edge cases worth knowing before now() appears in production code.
Common gotchas
Two calls are never equal
now() == now() is always FALSE. Each call captures a distinct instant.
now() == now()
# [1] FALSE
Wall-clock time, not monotonic time
now() is based on system time, which can jump due to NTP adjustments or manual clock changes. For measuring elapsed time, use base Sys.time() or the tictoc package.
Timezone is a display property
now("UTC") and now("America/New_York") have the same underlying numeric value. The tzone attribute controls only how that value is printed, not the instant itself.
now("UTC") == now("America/New_York")
# [1] TRUE
today() vs now() timezone behaviour differs
Because today() returns a Date (no time component), today() == today("GMT") can be FALSE if your local time is behind GMT and the UTC “today” has already rolled over to the next calendar day. now() does not have this issue.
now() returns a POSIXct datetime in the system timezone by default. Pass a timezone string to get the current time in another zone: now("UTC") or now("America/New_York"). Contrast with today(), which returns a Date without a time component. Both pull from the system clock at the moment of the call.
See also
- lubridate::ymd, parse dates from character or numeric input; pairs well with
now()when constructing timestamps - dplyr::filter() — row selection in tidyverse pipelines; commonly used after
now()to filter time-based records