How to subtract 2 hours from user's local time?
Subtract from another date object
var d = new Date();
d.setHours(d.getHours() - 2);
- Complete reference list for Date object
According to Javascript Date Documentation, you can easily do this way:
var twoHoursBefore = new Date();
twoHoursBefore.setHours(twoHoursBefore.getHours() - 2);
And don't worry about if hours you set will be out of 0..23
range.
Date() object will update the date accordingly.