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] "2018-06-30 15:19:36 UTC" "2019-09-09 14:01:27 UTC"
#>  [3] "2016-12-28 08:15:07 UTC" "2015-11-03 11:58:46 UTC"
#>  [5] "2019-04-10 10:00:26 UTC" "2014-10-31 16:48:03 UTC"
#>  [7] "2018-07-08 15:41:30 UTC" "2015-03-23 16:31:25 UTC"
#>  [9] "2014-08-02 15:21:21 UTC" "2015-09-21 07:51:26 UTC"
#> [11] "2019-08-22 13:36:25 UTC" "2017-11-13 16:36:50 UTC"