I want to generate some dates between two fixed values, but I don't know how to
use faker.date.between to achieve that.
the example in faker js demo is just giving a null value.
2 Answers
Not sure when did they update wiki, but they do have a working sample for date.between now
faker.date.between('2015-01-01', '2015-01-05'); 1Their code from Github shows:
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; }; And I don't know how you're using it, or why it's not working on their example.... But this should give you some direction, at least.
If this does not help you, or is still producing an undesired result, I would open an issue up on their github.