Node JS Get Hours Tutorial Example

15-Sep-2022

.

Admin

Node JS Get Hours Tutorial Example

Hi Frends,

In this example, I will show you the node js get hours tutorial example. This post will give you a simple example of the node.js get hours tutorial example. you can see the nodejs get hours tutorial example. it's a simple example of get hours tutorial example.

I will give you a simple example of get hours in node js. In this example get hours using getHours() in node js.

So let's start following example:

Step 1: Install Node JS


This step is not required; however, if you have not created the node js app, then you may go ahead and execute the below command:

mkdir my-app

cd my-app

npm init

Step 2: Update server.js file

server.js

const dateObject = new Date();

// current hours

const hours = dateObject.getHours();

console.log(hours);

Output:

10

I hope it can help you...

#Node JS