cur_date {ds4psy} | R Documentation |
Current date (in yyyy-mm-dd or dd-mm-yyyy format).
Description
cur_date
provides a relaxed version of
Sys.time()
that is sufficient for most purposes.
Usage
cur_date(rev = FALSE, as_string = TRUE, sep = "-")
Arguments
rev |
Boolean: Reverse from "yyyy-mm-dd" to "dd-mm-yyyy" format?
Default: |
as_string |
Boolean: Return as character string?
Default: |
sep |
Character: Separator to use.
Default: |
Details
By default, cur_date
returns Sys.Date
as a character string (using current system settings and
sep
for formatting).
If as_string = FALSE
, a "Date" object is returned.
Alternatively, consider using Sys.Date
or Sys.time()
to obtain the "
format according to the ISO 8601 standard.
For more options, see the documentations of the
date
and Sys.Date
functions of base R
and the formatting options for Sys.time()
.
Value
A character string or object of class "Date".
See Also
what_date()
function to print dates with more options;
date()
and today()
functions of the lubridate package;
date()
, Sys.Date()
, and Sys.time()
functions of base R.
Other date and time functions:
change_time()
,
change_tz()
,
cur_time()
,
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_date()
cur_date(sep = "/")
cur_date(rev = TRUE)
cur_date(rev = TRUE, sep = ".")
# return a "Date" object:
from <- cur_date(as_string = FALSE)
class(from)