Use the faker.date.between

Last Updated On Thursday 4th Nov 2021

faker js

	    var faker = require('faker');

    var randomName = faker.name.findName(); // Rowan Nikolaus
    var randomEmail = faker.internet.email(); // Kassandra.Haley@erich.biz
    var randomCard = faker.helpers.createCard(); // random contact card containing many properties
	

faker date

Generate massive amounts of realistic fake data in Node.js and the browser

	faker.date.between('2015-01-01', '2015-01-05');
	

faker.js

	self.between = function (from, to) {
  var fromMilli = Date.parse(from);
  var dateOffset = faker.random.number(Date.parse(to) - fromMilli);

  var newDate = new Date(fromMilli + dateOffset);

  return newDate;
};
	

References