10 examples of 'javascript date add hours' in JavaScript

Every line of 'javascript date add hours' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
13function addHours(d, hours) {
14 var newDate = clone(d);
15 newDate.setHours(d.getHours() + hours);
16 return newDate;
17}
10export default function addHours(time, hours) {
11 const t = new Date(time.getTime());
12 t.setHours(t.getHours() + hours);
13 return t;
14}
91addHours(hours) {
92 hours = hours || 0;
93 return this.addMilliseconds(hours * 3600000 /* Hour */);
94}
162add (date: Date, hours: number, dayType: Day = Day.REGULAR_DAY) {
163 this._times.push({date, hours, dayType})
164}
3452value: function addHour(h) {
3453 var now = new Date();
3454 now.setHours(now.getHours() + h);
3455 return now;
3456}
433value: function addHours(n) {
434 return this.addMinutes(n * 60);
435}
159function addMinutes(date, value) {
160 return new Date(+date + value * 60000);
161}
50function addMinutes(date, minutes) {
51 return new Date(date.getTime() + minutes * 60000);
52}
965'hours': function hours(date) {
966 return date.getHours();
967},
16function date_by_subtracting_hours(date, hours) {
17 return new Date(
18 date.getFullYear(),
19 date.getMonth(),
20 date.getDate(),
21 date.getHours() - hours,
22 date.getMinutes(),
23 date.getSeconds(),
24 date.getMilliseconds()
25 );
26}

Related snippets