cur_time: Current time (in hh:mm or hh:mm:ss format).

View source: R/time_fun.R

cur_timeR Documentation

Current time (in hh:mm or hh:mm:ss format).

Description

cur_time provides a satisficing version of Sys.time() that is sufficient for most purposes.

Usage

cur_time(seconds = FALSE, as_string = TRUE, sep = ":")

Arguments

seconds

Boolean: Show time with seconds? Default: seconds = FALSE.

as_string

Boolean: Return as character string? Default: as_string = TRUE. If as_string = FALSE, a "POSIXct" object is returned.

sep

Character: Separator to use. Default: sep = ":".

Details

By default, cur_time returns a Sys.time() as a character string (in " using current system settings. If as_string = FALSE, a "POSIXct" (calendar time) object is returned.

For a time zone argument, see the what_time function, or the now() function of the lubridate package.

Value

A character string or object of class "POSIXct".

See Also

what_time() function to print times with more options; now() function of the lubridate package; Sys.time() function of base R.

Other date and time functions: change_time(), change_tz(), cur_date(), days_in_month(), diff_dates(), diff_times(), diff_tz(), is_leap_year(), what_date(), what_month(), what_time(), what_wday(), what_week(), what_year(), zodiac()

Examples

cur_time() 
cur_time(seconds = TRUE)
cur_time(sep = ".")

# return a "POSIXct" object:
t <- cur_time(as_string = FALSE)
format(t, "%T %Z")


ds4psy documentation built on Sept. 15, 2023, 9:08 a.m.