Get random datetime vector

random_datetime_vector(
  size,
  min_date,
  max_date,
  date_format = NULL,
  date_unique = FALSE,
  min_time = "00:00:00",
  max_time = "23:59:59",
  time_resolution = "seconds",
  time_unique = FALSE,
  tz = "UTC"
)

Arguments

size

integer, vector length

min_date

character or date, beginning of the dates interval to sample from

max_date

character or date, ending of the dates interval to sample from

date_format

character, check strptime for details

date_unique

boolean, should the date part of the output be unique?

min_time

character, beginning of the time interval to sample from

max_time

character, ending of the time interval to sample from

time_resolution

character, one of "seconds", "minutes", "hours", time resolution

time_unique

boolean, should the time part of the output be unique?

tz

character, time zone to use

Examples

random_datetime_vector(12, "2012-12-04", "2020-10-31", min_time = "7:00:00", max_time = "17:00:00")
#>  [1] "2015-01-06 16:44:10 UTC" "2016-12-25 08:06:44 UTC"
#>  [3] "2016-06-06 09:02:52 UTC" "2014-10-18 14:53:19 UTC"
#>  [5] "2020-04-24 11:43:24 UTC" "2014-07-20 12:36:44 UTC"
#>  [7] "2018-09-20 15:31:18 UTC" "2015-11-09 12:33:11 UTC"
#>  [9] "2019-12-16 10:50:05 UTC" "2017-03-20 15:41:25 UTC"
#> [11] "2015-05-08 10:06:27 UTC" "2020-07-22 10:08:21 UTC"