You are viewing...

Pretty surprised at Javascript's Date Object

Updated on January 02, 2013 at the 02th hour
Posted under:

DISCLAIMER: All views are considered my own and you should not draw any conclusions on associates.

It makes it so easy to get the current time, date, timezone, and everything you could imagine except the idea of meridian time: AM and PM. It is workable to use the 24 hours time, but simplicity includes not making people have to think about what they are looking at (At least in my definition).

I was using NetBeans when I was looking at the Date object functions and saw this function: toLocaleFormat(). A locale formatter you say? Sounds like the best thing I've heard of. Printing the date/time with respect to a format and location of a person sounds great except it is not a standard function. Firefox gladly adheres to implementing this, while Chrome neglects it. =/ *Sigh*, so I went over to StackOverflow for a while to see if anyone has explained the disparity in implementation .. to no avail. Screw it then back to using toDate/TimeString, until I found a golden nugget. It's called MomentJS! The holy grail of date formatting! One simple function chain gets you from unix timestamp -> some crazy date format of your choice and in your timezone! Oh my gawd is what I'm saying even now!

Take a look at what Javascript's Date object should have been:

Moment.JS


 
You just read "Pretty surprised at Javascript's Date Object". Please share if you liked it!
You can read more recent posts here.