Ahmed Nuaman


builder of internets ~ developer of dreams ~ tamer of Dachshunds

FireFox has problems telling the time

Who’d have thought that FireFox has a problem telling the time? If you try and create a new ‘Date()’ object and set the time to zero, most browsers return 1st Jan 1970 at 00:00, however FireFox seems to think that I’m currently in BST and return 1:00am. Magic:

Here’s what Chrome says:
Chrome's representation of the time

And here’s what FireFox says:
FireFox's representation of the time

So, how does one get around this? Well with a bit of cunning it seems. FireFox returns ‘Date.getTimezoneOffset()’ as -60 and this is what we need to put the clocks back:

function formatTime(t)
{
    // a fix for FireFox's time issue
    var o   = t.getTimezoneOffset();
    var n   = o ? o / -60 : 0;
   
    return appendZero( t.getHours() - n ) + ':' + appendZero( t.getMinutes() ) + ':' + appendZero( t.getSeconds() )
}

var d = new Date();

d.setTime( 0 );

console.log( formateTime( d ) );

Where have comments gone?

Good question my old fruity. I'm now sticking any post discussions on Google+. Why? Well simply it's better. WordPress's comment system isn't very elegant and nor are ones like Disqus or Livefyre, so to save hassle I've just shipped them off to a social network, like a real boss.

Search

My social skills

Latest blog posts

  • Loading posts...

Subscribe in a reader

Latest tweets

  • Loading tweets...