I live in Hawaii where there is no Daylight Savings Time. I'm trying to show a world clock that displays dates and times from different time zones, but I also need it to properly calculate the DST offset. The limitation is that I must use the client time, as the application will not be able to get internet access. Is there a jQuery plugin that can handle this, or do I have to write it开发者_JAVA技巧 manually?
Does it HAVE to be a jQuery plugin?
There is a project on github that prototypes the Javascript Date object to be able to handle timezone keys
Regardless of how you do it, you will have to get the tzinfo database to work with your script (well, that's the only way I know of that will give you robust information about DST around the world). I have no personal experience of the library I linked above, but people seem to mention it from time to time, and it is the only pure JavaScript lib I have found to the tzinfo database.
function get_time_zone_offset( ) {
var current_date = new Date( );
var gmt_offset = current_date.getTimezoneOffset( ) / 60;
return gmt_offset;
}
精彩评论