Offset time for DST in one specific timezone using JavaScript
        Posted  
        
            by 
                Shannon
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Shannon
        
        
        
        Published on 2010-07-07T01:23:47Z
        Indexed on 
            2011/02/04
            23:25 UTC
        
        
        Read the original article
        Hit count: 319
        
I need to offset the time by an hour if it's currently DST in the Pacific Time Zone. How can I determine the current daylight savings status of the Pacific Time Zone, regardless of the user's local timezone?
Here's what I have so far. "dst" in line 4 is just a placeholder for a function that would tell me if daylight savings time is active in that zone.
function checkTime() {  
    var d = new Date();  
    var hour = d.getUTCHours();  
    var offset = dst ? 7 : 8; // is pacific time currently in daylight savings?
    // is it currently 6 AM, 2 PM, or 10 PM?
    if (hour === ((6 + offset) % 24) || hour === ((14 + offset) % 24) || hour === ((22 + offset) % 24)) {  
      // do stuff
    }
}
checkTime();
© Stack Overflow or respective owner