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;
}
More Related Contents:
- How to get date for nearest Sunday at 15:00 JST?
- How to sort an object array by date property?
- How to calculate date difference in JavaScript?
- How do you display JavaScript datetime in 12 hour AM/PM format?
- Why does the month argument range from 0 to 11 in JavaScript’s Date constructor?
- How to check if DST (Daylight Saving Time) is in effect, and if so, the offset?
- Difference between dates in JavaScript
- JavaScript: Which browsers support parsing of ISO-8601 Date String with Date.parse
- How can I convert string to datetime with format specification in JavaScript?
- How to get the day of week and the month of the year?
- How to parse a time into a Date object from user input in JavaScript?
- Converting .NET DateTime to JSON [duplicate]
- Moment js date time comparison
- JavaScript – Get minutes between two dates
- How to show current time in JavaScript in the format HH:MM:SS?
- Convert MySql DateTime stamp into JavaScript’s Date format
- How to JSON stringify a javascript Date and preserve timezone
- moment.js – UTC gives wrong date
- How to convert time in milliseconds to hours, min, sec format in JavaScript?
- Sort a string date array
- Compute elapsed time [duplicate]
- Javascript show milliseconds as days:hours:mins without seconds
- Javascript Convert Date Time string to Epoch
- Why isn’t “2016-02-16” equal to “2016-02-16 00:00”?
- Javascript return number of days,hours,minutes,seconds between two dates
- Javascript to convert UTC to local time
- Round a timestamp to the nearest date
- Hot to get incomplete datetime-local input values
- Does anyone know of a good JSON time server?
- Converting Google spreadsheet date into a JS Date object?