JavaScript Date Object Chrome vs. Firefox

There is a very tiny yet important difference between how Chrome and Firefox treats “Date” object, when you are creating one from a String:

new Date("1980-03-14T00:00:00.0000000");

The difference is that Firefox (tested on v23.0.1) considers the passed string is on the local timezone so the output is:

new Date("1980-03-14T00:00:00.0000000").toString();
"Fri Mar 14 1980 00:00:00 GMT-0400 (Eastern Standard Time)"

While Chrome, considers the passed string in UTC/GMT timezone and then converts it to a local timezone:

new Date("1980-03-14T00:00:00.0000000").toString();
"Thu Mar 13 1980 20:00:00 GMT-0400 (Eastern Daylight Time)"

As you can see, that would be a potential for some Front-End Date/Time processing.

If you are using the Date object just for showing, using the UTC format would be very useful and would avoid any discrepancies.


var my_time =  new Date("1980-03-14T00:00:00.0000000");
my_time.getUTCFullYear();
my_time.getUTCMonth();
my_time.getUTCDate()
Advertisements

JavaScript, how life has changed

If you’ve been a web-developer/design for a while, you definitely remember this picture :

What a headache ! huh ? I remember whenever I wrote a JavaScript code or snippet, when I hit F5 to run it, I was praying all the time not to see this freaking error message again. It gave no clue what’s going wrong, where the error is, and it did everything other than helping you out to solve the problem. Oh God! How much stupid Internet Explorer was (or maybe still is). Back then it was the most commonly used web-browser that we had to made our works compatible to.

Now we can do all the stuff we want with JavaScript, getting an error message is not much a problem anymore and debugging, is kind of fun. None of are because any change in the language itself or that stupid browser (Internet Explorer).

It’s all because of the great browser “FireFox” which was flexible enough for other third-party addons to be added to and make it enormously strong and usefull for web-developers/designers. All the tools from FireBug , Web developer toolbar and all the JavaScript Consoles (including the one which comes built-in with FireBug) have made our lives much easier.

FireFox has sort of pushed the web-browsing boundaries and forced all other existing web-browsers and the ones coming in future to be standard, and developers friendly (I’m not talking about IE, which I’m pretty glad I abandoned it since version 7).

I was thinking about the way our lives as developers/designers have changed and how much more we’re enjoying our jobs with out the need to struggle with very basic and dull stuff.

P.S: No need to mention about the JavaScript Frameworks and such pain relievers they are (most of the times though).

Yahoo! Mail + FireFox + Mac ; Home , End shortcuts issue

If you are a Firefox/Mac/Yahoo lover, you might have come across this annoying issue in Yahoo! Mail in Firefox [Mac version] that when you want to go to the home or end of a line with + Left  Arrow [command – left] or + Right Arrow [command – right] , it acts like a browser’s Back or Forward button and messes up the email you are composing or sometimes even ruins the whole thing.

You can see that everybody blames Yahoo! about not following the standard rules in their editor over the net. But this can be fixed through a very very simple FireFox add-on.
KeyConfig
is the handy tool for configuring your FireFox keyboard shortcuts. After installing if [and restarting the firefox] simply go to tools > KeyConfig and there search for “goBackKb” and “goForwardKb” and disable the ones allocated to + Left Arrow and + right Arrow.

From then on, on the newly opened windows this will be fixed and you will no longer have the same problem with those lovely combination [FireFox , Yahoo! , Mac]