how to get time in node js code example
Example 1: nodejs get current time
let date_ob = new Date();
let date = ("0" + date_ob.getDate()).slice(-2);
let month = ("0" + (date_ob.getMonth() + 1)).slice(-2);
let year = date_ob.getFullYear();
let hours = date_ob.getHours();
let minutes = date_ob.getMinutes();
let seconds = date_ob.getSeconds();
console.log(year + "-" + month + "-" + date);
console.log(year + "-" + month + "-" + date + " " + hours + ":" + minutes + ":" + seconds);
console.log(hours + ":" + minutes);
Example 2: how to get datetime in nodejs
let date_ob = new Date();
Example 3: javascript today date in epoch
const start = Date.now();