Use this function to transform generic date/time info writing (dd-mm-yyyy) into POSIX standardised format (%d-%m-%Y), see Examples.

format_datetime(format)

Arguments

format

the format that needs to be transformed

Value

A character string (a POSIX standardised format)

Examples

format_datetime("yyyy-mm-dd")
#> [1] "%Y-%m-%d"

# Very hard to remember all these characters:
format(Sys.time(), "%a %b %d %Y %X")
#> [1] "Sun Oct 30 2022 07:31:02"

# Easy to remember and write the same as above:
format(Sys.time(), format_datetime("ddd mmm dd yyyy HH:MM:ss"))
#> [1] "Sun Oct 30 2022 07:31:02"

# seconds since the Epoch, 1970-01-01 00:00:00
format(Sys.time(), format_datetime("epoch"))
#> [1] "1667115062"