I want to do some tests that needs alter process date when use Date class:
console.log(Date.now())
Running my program normally the process will get the machine current time:
"scripts": {
"start": "node testDate.js"
}
Is there something like cross-env to change initial process date?
"scripts": {
"start": "cross-env CURRENT_DATE=<future-date> node testDate.js"
}
Or is there a solution at runtime?
Can NodeJS change the process date like?
process.DATE_CLOCK=Date("<future-date>")
console.log(Date.now())// will print the future date + time passed after previous line has been executed
from How to change process date on NodeJS instead of change system date directly?
No comments:
Post a Comment