Thousands of tools! Check out Online Tools – I have now added thousands of tools.
I often have to generate random calendar dates so I created this simple online utility that does it for me. It lets you generate however many random years, months, and days you need from any date range. It works in the browser and is powered by alien technology from the future.
Random Date Generator Options
Random Date Generator Examples (click to try!)
2070-03-26 18:57:58 2014-05-11 11:51:20 2005-09-01 15:55:09 2014-07-28 07:15:08 2033-10-17 03:49:58 2058-09-07 19:26:25 2008-07-03 07:21:43 2039-04-12 19:03:14 2066-02-12 02:39:37 2099-08-17 06:38:10
Tuesday, January 26, 1926 04:33:34 am Sunday, February 11, 1827 07:26:23 pm Sunday, January 05, 1947 06:13:04 am Thursday, October 05, 2484 02:01:25 am Tuesday, November 13, 2187 11:30:40 am Sunday, December 01, 1957 00:14:38 am Sunday, September 08, 2571 03:31:33 am Saturday, May 04, 2599 07:27:26 pm Thursday, February 10, 2056 01:55:34 am Friday, March 26, 2799 07:34:31 am Thursday, March 04, 2297 04:06:39 am Sunday, September 14, 2166 05:06:29 am
17 Jan 2030, Thu | 3 Jul 2030, Wed | 23 Mar 2030, Sat | 26 Jul 2030, Fri | 15 Jun 2030, Sat | 27 Dec 2030, Fri
How Does This Random Date Generator Work?
This random calendar date generator works entirely in your browser and is written in JavaScript. It generates random dates from the calendar range startDate
to endDate
, which are specified in the options and use the YYYY-MM-DD HH:MM:SS
format. If you are working with just dates, then you can skip the hours, minutes, seconds part (the HH:MM:SS
part) as it's optional. The key idea that this program uses is that any point in time can be represented as a single integer number – the Unix timestamp (also known as the Unix Epoch). It's defined as the number of seconds that have passed since midnight (00:00:00 UTC) of Jan 1, 1970. It can be both a positive number (for example, 120
would be Jan 1, 1970 00:02:00) or a negative number (for example, -120
would be Dec 31, 1969, 23:58:00). To convert the date strings in the options to Unix time, the program uses a date parser that extracts the year y
, month mo
, day d
, hour h
, minute m
, second s
from startDate
and endDate
. If the clock time part is not specified, it's assumed to be 00:00:00. If the date or month components are not specified, then they are set to Jan 1. If the input time range is entered in 12-hour format, it's internally converted to a 24-hour format so that it was easier to work with. The program converts both input dates to the Coordinated Universal Time, as it's not adjusted for daylight saving time (so there are no surprises of missing hours). The UTC date is constructed via date = new Date(Date.UTC(y, mo, d, h, m, s))
and it's then converted to Unix time via startTimestamp = date.getTime()/1000
. Now the problem of generating a random date simply becomes a problem of generating random integers from the range [startTimestamp
, endTimestamp
]. Each picked integer is then converted back to UTC time via the formula new Date(randTimestamp*1000)
and then it's formatted to the necessary output format. The output format is represented as a string with the following keywords for various date and time parts: year YYYY
or YY
; month MMMM
, MMM
, or MM
; day DD
; day of the week dddd
, ddd
, or dd
; hour hh
; minute mm
; and second ss
. The formatting is performed by finding each date/time component X
with date.getUTCX()
and then substituting it back into the string via str.replace()
function. The required number of dates are generated in a for
loop that runs count
times (specified in options). The results are stored in the array randDates
. If the duplicate date filter option is enabled, the program checks the uniqueness of each randDate
by keeping a track of already generated dates is in the seenDates
object. At the end of the loop, the program calls randDates.join()
function and returns all dates, joined via separator
to the screen.
Created by Browserling
This random date generator was created by me and my team at Browserling. Behind the scenes, it's actually powered by our web developer tools that are used by millions of people every month. Browserling itself is an online cross-browser testing service powered by alien technology. Check it out!
Secret message: If you love my tools, then I love you, too! Use coupon code TOOLLING to get a discount at my company.