Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

date add 1 hour javascript

//JS
function addHoursToDate(date, hours) {
  return new Date(new Date(date).setHours(date.getHours() + hours));
}

//TS
function addHoursToDate(date: Date, hours: number): Date {
  return new Date(new Date(date).setHours(date.getHours() + hours));
}

let myDate = new Date();

console.log(myDate)
console.log(addHoursToDate(myDate,2))
Comment

javascript add hours

function addHours(hours, date = new Date()) {
  let ms = hours * 60 * 60 * 1000;
  date.setTime(date.getTime() + ms);
  return date;
}
Comment

date add hours javascript

Date.prototype.addHours = function(h) {
  this.setTime(this.getTime() + (h*60*60*1000));
  return this;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: isarray 
Javascript :: video preview javascript 
Javascript :: search no of item in array 
Javascript :: react native release apk command 
Javascript :: livewire file upload progress 
Javascript :: get size of json object 
Javascript :: regex any char except 
Javascript :: javascript ES6 destructure dynamic property name 
Javascript :: query selector has clas 
Javascript :: react-native-reanimated npm 
Javascript :: how to loop through date range in javascript 
Javascript :: SAPUI5 formatter Date and Time 
Javascript :: multidimensional array push in jquery 
Javascript :: how to get all form values in javascript 
Javascript :: push notification javascript 
Javascript :: for loop condition javascript 
Javascript :: classlist.toggle 
Javascript :: express trust proxy 
Javascript :: regex for company name 
Javascript :: array contains object in javascript 
Javascript :: get message author discord.js 
Javascript :: Uncaught TypeError: console.log is not a function 
Javascript :: javascript onclick to another page div 
Javascript :: sequelize sync 
Javascript :: delay statement in js 
Javascript :: lodash deep compare two objects 
Javascript :: javascript sum of array 
Javascript :: ajax post variable values 
Javascript :: npm ERR! missing script: start 
Javascript :: react dictionary key value avec 2 variable 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =