Wolfram Research

Function Repository Resource:

RandomTime

Source Notebook

Generate a random time

Contributed by: Sander Huisman  |  SHuisman

ResourceFunction["RandomTime"][]

generates a random time.

ResourceFunction["RandomTime"][n]

generates n random times.

ResourceFunction["RandomTime"][type]

generates a random time of type type.

ResourceFunction["RandomTime"][type,n]

generates n random times of type type.

Details

ResourceFunction["RandomTime"][All] outputs all possible types: "Hour", "HalfHour", "Quarter", "Minute", "Second", "Instant".

Examples

Basic Examples (4) 

Generate a random time:

In[1]:=
ResourceFunction["RandomTime"][]
Out[1]=

Generate multiple times:

In[2]:=
ResourceFunction["RandomTime"][5]
Out[2]=

Generate times with minute granularity:

In[3]:=
ResourceFunction["RandomTime"]["Minute", 5]
Out[3]=

Generate times with quarter granularity:

In[4]:=
ResourceFunction["RandomTime"]["Quarter", 5]
Out[4]=

Scope (1) 

Generate a single random time with half-hour granularity:

In[5]:=
ResourceFunction["RandomTime"]["HalfHour"]
Out[5]=

Resource History

Related Resources

License Information