JavaScript itself has terrible Date/Time API's. Nonetheless, you can do this in pure JavaScript:

Date.prototype.addHours = function(h) {
  this.setTime(this.getTime() + (h*60*60*1000));
  return this;
}
Answer from Jason Harwig on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › setHours
Date.prototype.setHours() - JavaScript | MDN
The setHours() method of Date instances changes the hours, minutes, seconds, and/or milliseconds for this date according to local time. const event = new Date("August 19, 1975 23:15:30"); event.setHours(20); console.log(event); // Expected output: "Tue Aug 19 1975 20:15:30 GMT+0200 (CEST)" ...
🌐
JavaScript in Plain English
javascript.plainenglish.io › javascript-add-hours-to-date-6e3a39bb9345
How to Add Hours to a Date in JavaScript | JavaScript in Plain English
July 23, 2024 - function addHours(date, hours) { const hoursToAdd = hours * 60 * 60 * 1000; date.setTime(date.getTime() + hoursToAdd); return date; }const date = new Date('2022-05-15T12:00:00.000Z');const newDate1 = addHours(date, 2); console.log(newDate1); ...
🌐
Futurestud.io
futurestud.io › tutorials › add-hours-to-a-date-in-javascript-or-node-js
Add Hours to a Date in JavaScript or Node.js
The getHours returns the current number of hours of a given date. And the setHours method changes the hour of a given date instance. The nice thing here is that JavaScript takes care of changing the day/month/year in case the added hours shift something of that.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-adding-hours-to-the-date-object
JavaScript Adding hours to the Date object - GeeksforGeeks
July 11, 2025 - JavaScript setHours() Method: This method sets the hour of a date object. We can also set the minutes, seconds and milliseconds. ... hour: This parameter is required. It specifies the integer representing the hour.
🌐
30 Seconds of Code
30secondsofcode.org › home › javascript › date › add minutes, hours or days to date
How can I add minutes, hours or days to a JavaScript date? - 30 seconds of code
January 5, 2024 - const addMinutesToDate = (date, ... 11:50:00 · To add hours to a date, we can multiply the number of milliseconds in an hour (1000 * 60 * 60) before setting the time....
🌐
Readthedocs
momentjscom.readthedocs.io › en › latest › moment › 03-manipulating › 01-add
Add - momentjs.com
If you are adding hours, minutes, seconds, or milliseconds, the assumption is that you want precision to the hour, and will result in a different hour. var m = moment(new Date(2011, 2, 12, 5, 0, 0)); // the day before DST in the US m.hours(); // 5 m.add(24, 'hours').hours(); // 6 (but you may have to set the timezone first)
🌐
TutorialsPoint
tutorialspoint.com › How-to-add-2-hours-to-a-JavaScript-Date-object
How to add 2 hours to a JavaScript Date object?
To add 2 hours into the Date object using the setHours() method first we get the value of hours of the current time and then add 2 into it and pass the added value to the setHours() method.
🌐
W3Schools
w3schools.com › jsref › jsref_sethours.asp
JavaScript Date setHours() Method
cssText getPropertyPriority() ... · const d = new Date("2025-01-15"); d.setHours(15); Try it Yourself » · setHours() sets the hour of a date....
Find elsewhere
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-date-add-hours
How to Add Hours to a Date in JavaScript | bobbyhadz
The addHours function takes a Date object and N as parameters and adds N hours to the date.
🌐
Envato Tuts+
webdesign.tutsplus.com › home › web design › html/css › javascript for designers
How to Add and Subtract Time From a Date in JavaScript | Envato Tuts+
September 19, 2023 - Basically, we’ve just multiplied the number of minutes in an hour (60) by the number of seconds in a minute (60) by the number of milliseconds in a second (1000) to get the number of milliseconds in an hour. As you might already know, you can initialize a Date object by providing the number of milliseconds as the first argument, and this would initialize a date object in reference to it. Thus, we’ve added numberOfMlSeconds and addMlSeconds to get the total number of milliseconds, and we’ve used it to initialize a new date object.
🌐
Medium
medium.com › @glasshost › add-hours-to-a-date-in-javascript-7f4a461a7a2a
Add Hours to a Date in JavaScript | by Glasshost | Medium
April 12, 2023 - This code adds three hours to the current date by getting the current hour using the getHours() method, and then adding three to it using the + operator.
🌐
TutorialsPoint
tutorialspoint.com › article › How-to-add-hours-and-minutes-to-a-date-with-JavaScript
How to add hours and minutes to a date with JavaScript?
Add hours or minutes with the getTime() Method. JavaScript date setHours() method sets the hours for a specified date according to local time.
🌐
Day.js
day.js.org › docs › en › manipulate › add
Add · Day.js
result = dayjs().add(dayjs.duration({'days' : 1}))
🌐
Go Make Things
gomakethings.com › adding-time-with-vanilla-javascript
Adding time with vanilla JavaScript | Go Make Things
The Date() object provides a handful of instance methods that you can use to get and modify the date and time. They follow a get*() and set*() naming convention, where * is the property to get or set. For example, to get the hours and month ...
🌐
Delft Stack
delftstack.com › home › howto › javascript › javascript date add hours
How to Add Hours to Date Object in JavaScript | Delft Stack
February 2, 2024 - To add the hour’s value, we will create a function called addHours(), which will take a single parameter hr that will be an integer value representing the hour value that we want to add to the current time.
🌐
Attacomsian
attacomsian.com › blog › javascript-date-add-hours
How to add hours to a date in JavaScript
September 10, 2022 - Learn how to use the getTime() and setTime() methods of date object to add hours to date in JavaScript.
🌐
W3Schools
w3schools.com › js › js_date_methods_set.asp
JavaScript Date Set Methods
If adding days shifts the month or year, the changes are handled automatically by the Date object. The setHours() method sets the hours of a date object (0-23):
🌐
GeeksforGeeks
geeksforgeeks.org › node-js-date-addhours-api
Node.js Date.addHours() API | GeeksforGeeks
March 12, 2021 - // Node.js program to demonstrate the // Date.addHours() method // Importing module const date = require('date-and-time') // Creating object of current date and time // by using Date() const now = new Date(); now.setDate(20) // Adding Hours ...
🌐
CodexWorld
codexworld.com › home › how to guides › how to add hours to javascript date object
How to Add Hours to JavaScript Date Object - CodexWorld
August 12, 2016 - JavaScript setHours() method sets the hour of a date object. JavaScript getHours() method returns the hour (from 0 to 23) of the specified date and time. Using JavaScript setHours() and getHours() method you can easily add hours to Date object.