Formatted dates and times.

date_format(format = "%Y-%m-%d", tz = "UTC")

time_format(format = "%H:%M:%S", tz = "UTC")

Arguments

format

Date/time format using standard POSIX specification. See strptime() for possible formats.

tz

a time zone name, see timezones(). Defaults to UTC

Examples

a_time <- ISOdatetime(2012, 1, 1, 11, 30, 0, tz = "UTC") a_date <- as.Date(a_time) date_format()(a_date)
#> [1] "2012-01-01"
date_format(format = "%A")(a_date)
#> [1] "Sunday"
time_format()(a_time)
#> [1] "11:30:00"
time_format(tz = "Europe/Berlin")(a_time)
#> [1] "12:30:00"
a_hms <- hms::as.hms(a_time, tz = "UTC") time_format(format = "%H:%M")(a_hms)
#> [1] "11:30"