RandomTime
✖
RandomTime
gives a pseudorandom time between now and the time quantity duration from now.
Details and Options

- RandomTime is used to generate time objects within a particular time period (i.e. a given hour, minute, second or a set of arbitrary points in time).
- RandomTime[{timemin,timemax}] chooses times with a uniform probability distribution between timemin and timemax.
- RandomTime[time] gives a time between the beginning and end of the specified time, based on its granularity, and is equivalent to RandomTime[DateBounds[time]]. Specifications for time may be a DateObject, TimeObject or DateInterval.
- RandomTime[quantity] gives a time between Now and Now+quantity, where quantity is a duration specified using Quantity with a time unit. RandomTime[{quantitymin,quantitymax}] gives a time between Now+quantitymin and Now+quantitymax.
- RandomTime[range,{n1,n2,…}] gives an n1×n2×… array of pseudorandom times.
- The following options can be specified for generated times:
-
DateGranularity Automatic granularity of generated times TimeZone Automatic time zone of generated times - RandomTime gives a different sequence of pseudorandom times whenever you run the Wolfram Language. You can start with a particular seed using SeedRandom.
Examples
open allclose allBasic Examples (7)Summary of the most common use cases

https://wolfram.com/xid/0cg48hc9e-e9j

A random time between 6am and 4pm:

https://wolfram.com/xid/0cg48hc9e-2tusnn

A random time between noon and 1pm:

https://wolfram.com/xid/0cg48hc9e-d8m

A random time between now and 3 hours from now:

https://wolfram.com/xid/0cg48hc9e-yu4

A random time in the past two minutes:

https://wolfram.com/xid/0cg48hc9e-eafasf

A random time between the next hour and the hour after:

https://wolfram.com/xid/0cg48hc9e-x2xid0

Five random times between 3 and 4am:

https://wolfram.com/xid/0cg48hc9e-g3t9f9

Options (2)Common values & functionality for each option
DateGranularity (1)
By default, times are generated with "Instant" granularity:

https://wolfram.com/xid/0cg48hc9e-6z61y0

Use DateGranularity"Minute" to generate a pseudorandom minute:

https://wolfram.com/xid/0cg48hc9e-zi2tqw

Wolfram Research (2022), RandomTime, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomTime.html.
Text
Wolfram Research (2022), RandomTime, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomTime.html.
Wolfram Research (2022), RandomTime, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomTime.html.
CMS
Wolfram Language. 2022. "RandomTime." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RandomTime.html.
Wolfram Language. 2022. "RandomTime." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RandomTime.html.
APA
Wolfram Language. (2022). RandomTime. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RandomTime.html
Wolfram Language. (2022). RandomTime. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RandomTime.html
BibTeX
@misc{reference.wolfram_2025_randomtime, author="Wolfram Research", title="{RandomTime}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/RandomTime.html}", note=[Accessed: 21-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_randomtime, organization={Wolfram Research}, title={RandomTime}, year={2022}, url={https://reference.wolfram.com/language/ref/RandomTime.html}, note=[Accessed: 21-March-2025
]}