From: http://amix.dk/blog/viewEntry/19360 function addToDate ( date , hours , minutes ) { var m_secs = date . getTime (); var local_offset = date . getTimezoneOffset () * 60 * 1000 ; var utc_m_secs = m_secs + local_offset ; if ( hours ) utc_m_secs += hours * 60 * 60 * 1000 ; if ( minutes ) utc_m_secs += minutes * 60 * 1000 ; return new Date ( utc_m_secs ); }
Example: var four_hours_ago = addToDate ( new Date () , -4 );