84033/how-do-i-get-the-time-of-day-in-javascript-node-js
I want to get 1 to 24, 1 being 1am Pacific Time.
How can I get that number in Node.JS?
I want to know what time it is in Pacific time right now.
Hello @kartik,
This function will return you the date and time in the following format: YYYY:MM:DD:HH:MM:SS. It also works in Node.js.
function getDateTime() { var date = new Date(); var hour = date.getHours(); hour = (hour < 10 ? "0" : "") + hour; var min = date.getMinutes(); min = (min < 10 ? "0" : "") + min; var sec = date.getSeconds(); sec = (sec < 10 ? "0" : "") + sec; var year = date.getFullYear(); var month = date.getMonth() + 1; month = (month < 10 ? "0" : "") + month; var day = date.getDate(); day = (day < 10 ? "0" : "") + day; return year + ":" + month + ":" + day + ":" + hour + ":" + min + ":" + sec; }
Hope it work!!
Thank You!!
Hello @kartik, You can use req.headers["accept-language"] to get the language/locale ...READ MORE
Hello @kartik, With Node.js v6 (and above) there ...READ MORE
Hello @kartik, The built-in module querystring is what you're looking ...READ MORE
Hello @kartik, Try this one: console.log("Session: %j", session); If the ...READ MORE
Hey @kartik, First you have to go to ...READ MORE
Named route is used to give specific ...READ MORE
Hello, This is simple you just need to ...READ MORE
Hey @kartik, Named routing is another amazing feature of ...READ MORE
Hello @kar You can do the following to ...READ MORE
Hello @kartik, you can do this: fs.readFile(path.resolve(__dirname, 'settings.json'), 'UTF-8', ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.