Date function to convert character/other as.POSIXct to date.
date_fun(x, tz = "EST", form = "%F")
as.POSIXct or as.character
timezone (default set to Eastern Standard Time)
format (default set to YYYY-mm-dd)
Helper function to format date (and date-time) fields
datetime=as.character(c("2015-05-01 08:00:00","2015-10-15 12:00:00","2015-10-15 5:00:00"))
date.fun(datetime);# just date
#> [1] "2015-05-01 EST" "2015-10-15 EST" "2015-10-15 EST"
date.fun(datetime, form="%F %X"); #include date and time
#> [1] "2015-05-01 08:00:00 EST" "2015-10-15 12:00:00 EST"
#> [3] "2015-10-15 05:00:00 EST"
date.fun("2020-05-01")
#> [1] "2020-05-01 EST"
date.fun(as.Date("2020-05-01"))
#> [1] "2020-05-01 EST"
date.fun(as.POSIXct("2020-05-01 12:00:00",tz="EST"),form="%F %H:%M:%S")
#> [1] "2020-05-01 12:00:00 EST"
date.fun(as.POSIXct("2020-05-01 12:00:00",tz="UTC"),form="%F %H:%M:%S")
#> [1] "2020-05-01 07:00:00 EST"