Mockdate

mockdate

Mock Date object that can be used to change when "now" is.

mockdate the names says it all!

This module save the current date context to _date and _getTimezoneOffset = Date.prototype.getTimezoneOffset internally and overwrites them with simpler custom implementation which would useful for unit tests et.al

Get it: npm install --save mockdate

Sample usage:

1
2
3
4
const mockDate = require('mockdate');
mockDate.set('2/1/1988',120);
new Date()
1988-01-31T18:30:00.000Z

GIF FTW!

mockdate

Suggest a module

Comments