Learn R Programming

LightLogR (version 0.10.0)

style_time: Style (date)times as times

Description

This function takes a numeric input vector, converts them to an hms (using hms::as_hms()), then to a POSIXlt (using base::as.POSIXlt()), and then formats is according to the format argument.

Usage

style_time(x, format = "%H:%M")

Value

a character vector of length(x)

Arguments

x

a numeric vector to be styled

format

output format. Defaults to "%H:%M", which results in, e.g., "03:45". Look to base::strptime() for formatting options.

Examples

Run this code
#collect some time info
time <- 
sample.data.irregular |> 
dplyr::slice(300:305) |> 
dplyr::pull(Datetime)

#Output is of type POSIXct
time

time |> style_time()

Run the code above in your browser using DataLab