Here, we will write a program to create our own module and import it into our js file. In your directory make a myModule.js file and create myDateTime() function.
Mymodule.js file
var myDateTime = function () {
return Date();
};
module.exports=myDateTime;
In your index.js file export the above module using require. And then run the file in the terminal.
index.js file
var myDateTime=require('./myModule');
console.log(myDateTime());